This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.io.InputStream; | |
import java.util.concurrent.ArrayBlockingQueue; | |
import java.util.concurrent.BlockingQueue; | |
import java.util.concurrent.ThreadFactory; | |
import java.util.concurrent.TimeUnit; | |
import java.util.concurrent.atomic.AtomicInteger; | |
import org.apache.commons.logging.Log; | |
import org.apache.commons.logging.LogFactory; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
import java.util.Base64; | |
import javax.crypto.Cipher; | |
import javax.crypto.SecretKey; | |
import javax.crypto.SecretKeyFactory; | |
import javax.crypto.spec.DESedeKeySpec; | |
import javax.crypto.spec.IvParameterSpec; | |
public class GenerateCipheredText { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _loadPortletsData = function(page) { | |
var deferred = $q.defer(); // or other deferred object like jQuery.Deferred(); | |
var promise = deferred.promise; | |
var count = 0; | |
_.map(page.columns, function(column) { | |
_.map(column.portlets, function(portlet) { | |
++count; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// bind safe html in AngularJS | |
angular.module('myModule', ['ngSanitize']) | |
.directive('tgBindSafeHtml', ['$sce', '$sceDelegate', '$parse', '$compile', | |
function($log, $sce, $sceDelegate, $parse, $compile) { | |
return { | |
restrict: 'A', | |
compile: function ngBindHtmlCompile(tElement, tAttrs) { | |
var ngBindHtmlGetter = $parse(tAttrs.tgBindSafeHtml); | |
var ngBindHtmlWatch = $parse(tAttrs.tgBindSafeHtml, function getStringValue(value) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int t1 = (100 - 128) >> 31; | |
int t2 = (200 - 128) >> 31; | |
System.out.println(Integer.toBinaryString(t1)); | |
System.out.println(Integer.toBinaryString(t2)); | |
System.out.println(); | |
int t = 1; | |
System.out.println(Integer.toBinaryString(t) + " L shifted by 0:\t" + Integer.toBinaryString(t << 0)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://docs.python.org/2/library/functools.html#functools.update_wrapper | |
from functools import wraps | |
def wrapped_func1(func): | |
def __inner_func(): | |
return func() | |
return __inner_func | |
def wrapped_func2(func): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.liferay.portal.service; | |
import java.lang.ref.Reference; | |
import java.lang.ref.ReferenceQueue; | |
import java.lang.ref.WeakReference; | |
import java.util.HashMap; | |
import java.util.Map; | |
public class ReferencesTest { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
php > $x = 123; | |
php > $var4 = static function() use(&$x) {return $x;}; // with 'static' | |
php > echo $var4(); | |
123 | |
php > echo (function() use(&$x) {return $x;})(); | |
123 | |
php > $var4 = (function() use(&$x) {return $x;}); // without 'static' | |
php > echo $var4(); | |
123 | |
php > $x = 321; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# bash generate random alphanumeric string | |
# | |
# bash generate random 32 character alphanumeric string (upper and lowercase) and | |
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) | |
# bash generate random 32 character alphanumeric string (lowercase only) | |
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var createPromise = function(label, time) { | |
return function() { | |
return new Promise(function(resolve) { | |
setTimeout(function() { | |
console.log(label); | |
resolve(); | |
}, time); |
OlderNewer