public static MyClass {
private static volatile ProcessManager singleton = null;
public static ProcessManager getInstance() throws Exception {
if (singleton == null) {
synchronized (MyClass.class) {
if (singleton == null) {
singleton = new ProcessManager();
}
}
}
return singleton;
}
}
The double-checking was invented prior to Java5.
The purpose is if the field isn't null, you don't have to synchronize. But since the java memory model specification was cleaned up and Synchronize/Volatile were given much better specification and semantics it is totally useless boilerplate that you should only write if you have to support Java4. There is a Google Tech Talk that covers this.
// Return flagged enum with inverted selected flag value
public static TEnum SwapFlag<TEnum>(this TEnum target, TEnum flag) where TEnum : Enum
{
if (target.HasFlag(flag)) return (TEnum)(object)((int)(object)target & ~(int)(object)flag);
return (TEnum)(object)((int)(object)target | (int)(object)flag);
}
<?php
if(isset($_POST['csrf'])){
if($_POST['csrf'] !== $_SESSION['csrf']){
return 'session expired!';
}
}
In all Sama Samaneh
university and class management system from iran :)
if ($this->getTestSku()) {
...
} elseif ($this->getTestOffset() >= 0 && $this->getTestLimit() > 0) {
...
} else {
Mage::throwException(sprintf("Invalid parameters for test mode: sku %s or offset %s and limit %s", $this->getTestSku(), $this->getTestOffset(), $this->getTestLimit()));
}
// IsFooBar being a boolean, we check if it's different from true and from false
if (x.IsFooBar != true && x.IsFooBar != false)
{
return "error";
}
x.IsFooBar is juste a regular bool
div.body:first-child:nth-last-child(n+12),
div.body:first-child:nth-last-child(n+12) ~ div.body {
padding: 3px 5px 2px !important;
div.rect {
top: 6px !important;
}
div.legend-action {
top: 3px !important;
}
}
/**
* Deserializes the contents of the incoming message buffer {@code b}.
*
* @return deserialised object
* @throws UnsupportedEncodingException If the named charset is not supported
*/
Object r() throws UnsupportedEncodingException{
int i=0, n, t=b[j++];
if(t<0)
switch(t){
case -1:
return rb();
case (-2):
return rg();
case -4:
return b[j++];
case -5:
return rh();
case -6:
return ri();
case -7:
return rj();
case -8:
return re();
case -9:
return rf();
case -10:
return rc();
case -11:
return rs();
case -12:
return rp();
case -13:
return rm();
case -14:
return rd();
case -15:
return rz();
case -16:
return rn();
case -17:
return ru();
case -18:
return rv();
case -19:
return rt();
}
if(t>99){
if(t==100){
rs();
return r();
}
if(t<104)
return b[j++]==0&&t==101?null:"func";
if(t>105)
r();
else
for(n=ri();i<n;i++)
r();
return "func";
}
if(t==99)
return new Dict(r(),r());
j++;
if(t==98)
return new Flip((Dict)r());
n=ri();
switch(t){
case 0:
Object[] L=new Object[n];
for(;i<n;i++)
L[i]=r();
return L;
case 1:
boolean[] B=new boolean[n];
for(;i<n;i++)
B[i]=rb();
return B;
case 2: {
UUID[] G=new UUID[n];
for(;i<n;i++)
G[i]=rg();
return G;
}
case 4:
byte[] G=new byte[n];
for(;i<n;i++)
G[i]=b[j++];
return G;
case 5:
short[] H=new short[n];
for(;i<n;i++)
H[i]=rh();
return H;
case 6:
int[] I=new int[n];
for(;i<n;i++)
I[i]=ri();
return I;
case 7:
long[] J=new long[n];
for(;i<n;i++)
J[i]=rj();
return J;
case 8:
float[] E=new float[n];
for(;i<n;i++)
E[i]=re();
return E;
case 9:
double[] F=new double[n];
for(;i<n;i++)
F[i]=rf();
return F;
case 10:
char[] C=new String(b,j,n,encoding).toCharArray();
j+=n;
return C;
case 11:
String[] S=new String[n];
for(;i<n;i++)
S[i]=rs();
return S;
case 12:
Timestamp[] P=new Timestamp[n];
for(;i<n;i++)
P[i]=rp();
return P;
case 13:
Month[] M=new Month[n];
for(;i<n;i++)
M[i]=rm();
return M;
case 14:
Date[] D=new Date[n];
for(;i<n;i++)
D[i]=rd();
return D;
case 15:
java.util.Date[] Z=new java.util.Date[n];
for(;i<n;i++)
Z[i]=rz();
return Z;
case 16:
Timespan[] N=new Timespan[n];
for(;i<n;i++)
N[i]=rn();
return N;
case 17:
Minute[] U=new Minute[n];
for(;i<n;i++)
U[i]=ru();
return U;
case 18:
Second[] V=new Second[n];
for(;i<n;i++)
V[i]=rv();
return V;
case 19:
Time[] T=new Time[n];
for(;i<n;i++)
T[i]=rt();
return T;
}
return null;
}
Manually maintained open-source code on GitHub. Looks like decompiled from obfuscated binary, they just reformatted it, added some comments and now are making manual changes. Current version: https://github.com/KxSystems/javakdb/blob/master/src/kx/c.java Original version: https://github.com/KxSystems/javakdb/blob/c9afe6fa32d7d3e3cddabdc9bd43f0155a5d2a1b/src/kx/c.java
//https://gist.github.com/nim4n136/7fa38467181130f5a2270c39d495101e
function decrypt($msg_encrypted_bundle, $password){
$password = sha1($password);
$components = explode( ':', $msg_encrypted_bundle );
$iv = $components[0];
$salt = hash('sha256', $password.$components[1]);
$encrypted_msg = $components[2];
$decrypted_msg = openssl_decrypt(
$encrypted_msg, 'aes-256-cbc', $salt, null, $iv
);
if ( $decrypted_msg === false )
return false;
return $decrypted_msg;
}
private void EnableGPSAutoMatically() {
GoogleApiClient googleApiClient = null;
if (googleApiClient == null) {
oogleApiClient = new GoogleApiClient.Builder(this)
.addApi(LocationServices.API).addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).build();
/* about 50 lines of code were here ...
* all depends on this if statement ... !
* Actually the whole method depends on this if statement ! */
}
}
});
}
}
what if that mysterious power change it to be not null !! It gonna be a holly object and You should not "new" it anymore ?! damn ... :)))
abstract class ASong(
var songId: Int = 0,
var title: String? = "",
var clipArt: String? = "",
var artist: String? = "",
var source: String? = "",
var songType: Int = 0,
var length: String? = "",
var downloadPath: String? = "",
var category: String? = ""
) : Parcelable {
@Transient
var totalDuration: Long = 0
@Transient
var currentPosition: Long = 0
@Transient
var playingPercent = 0
private fun calculatePlayingPercent(): Int {
return if (currentPosition == 0L || totalDuration == 0L) 0 else (currentPosition * 100 / totalDuration).toInt()
}
}
© 2021 GitHub, Inc
Probably meant to stand for AbstractSong. Ens up sounding awkward or like somebody who just wrote their first class.
boolean isUserAuthorized = user.isSuperAdmin();
if (!isUserAuthorized) {
isUserAuthorized = isUserAdminOfEntity1();
}
if (!isUserAuthorized) {
isUserAuthorized = isUserAdminOfEntity2();
}
if (!isUserAuthorized) {
throw new AccessDeniedException("Authenticated user is not admin ");
}
//Calculates x² of an integer up to ±1 million
var square = (function () {
var s = "if(A==B){return C;}";
var func = "var A=Math.abs(D|0);";
for (var i = 0; i <= 1000000; i++) {
func += s.replace(/B/, i).replace(/C/, i * i);
}
return new Function("D", func + "return Infinity;");
})();
function deleteConfirm() {
var result = confirm("Are you sure to delete this customer ?");
if (result) {
return true;
} else {
return false;
}
}
@define
class DedupConfig:
columns_to_dedup_by: Optional[List]
time_range_in_minutes: Optional[int]
timestamp_column_name: Optional[str]
leave_deduped_samples_in_time_range: Optional[int] = field(default=1)
def __attrs_post_init__(self):
if not self.timestamp_column_name:
raise ValueError(f"timestamp_column_name parameter must be provided")
if not self.columns_to_dedup_by:
raise ValueError(f"columns_to_dedup_by parameter must be provided")
if not self.time_range_in_minutes:
raise ValueError(f"time_range_in_minutes parameter must be provided")
const convertMenu = menus => {
const menusAssinged = menus.filter(menu => menu.parentId == null).sort((a, b) => a.order - b.order).map(menu => {
if (menus.some(element => element.parentId == menu.menuId)) {
return {
title: menu.title,
icon: { icon: menu.icon },
children: menus.filter(menuChil => menuChil.parentId == menu.menuId).sort((a, b) => a.order - b.order).map(menuChil => {
if (menuChil.pathRoute.includes(":")) {
const params = menuChil.pathRoute.split(":").pop()
return {
title: menuChil.title,
to: { name: menuChil.nameRoute, params: { [params]: "abc" } },
}
} else {
return {
title: menuChil.title,
to: menuChil.nameRoute,
}
}
}),
}
} else {
return {
title: menu.title,
icon: { icon: menu.icon },
to: menu.nameRoute,
}
}
})
menusUser.value = menusAssinged
localStorage.setItem('menus', JSON.stringify(menusAssinged))
}
when they exorcise the callbacks demon but they appear in functional