Skip to content

Instantly share code, notes, and snippets.

View SleeplessByte's full-sized avatar
💎
💎 💎 💎

Derk-Jan Karrenbeld SleeplessByte

💎
💎 💎 💎
View GitHub Profile
@SleeplessByte
SleeplessByte / silly.js
Created February 3, 2014 18:40
Javascript is silly
"J"+(([]===[])+/-/)[1]+/\[[^1]+\]/[([]+![])[1<<1<<1]+(/|/[(1+{})[1+11>>>1]+[[]+{}][+!1][1]+([]+1/[])[1<<1>>1]+([1<1]+[])[1+11>>>1+1]+[[!!1]+1][+[]][1-1]+([]+!!/!/)[1|1]+(/1/[1]+[])[!1%1]+(-{}+{})[-1+1e1-1]+(1+[!!1])[1]+([]+1+{})[1<<1]+[!!/!!/+[]][+[]][1&1]]+/=/)[1e1+(1<<1|1)+(([]+/-/[(!!1+[])[1>>1]+(!!1+[])[1<<1^1]+(!1+[])[1|1<<1]+(!!1+[])[1^1]])[1^1]==+!1)]+(!![]+{})[1|1<<1]+[1+{}+1][!1+!1][(11>>1)+1]](([]+/-/[(!!1+[])[1>>1]+(!!1+[])[1<<1^1]+(!1+[])[1|1<<1]+(!!1+[])[1^1]]))[1&.1][11>>>1]+(([]===[])+/-/)[1]+([1<1]+[])[1+11>>>1+1]+(1+{})[1+11>>>1]+[!!/!!/+[]][+[]][1&1]+/\[[^1]+\]/[([]+![])[1<<1<<1]+(/|/[(1+{})[1+11>>>1]+[[]+{}][+!1][1]+([]+1/[])[1<<1>>1]+([1<1]+[])[1+11>>>1+1]+[[!!1]+1][+[]][1-1]+([]+!!/!/)[1|1]+(/1/[1]+[])[!1%1]+(-{}+{})[-1+1e1-1]+(1+[!!1])[1]+([]+1+{})[1<<1]+[!!/!!/+[]][+[]][1&1]]+/=/)[1e1+(1<<1|1)+(([]+/-/[(!!1+[])[1>>1]+(!!1+[])[1<<1^1]+(!1+[])[1|1<<1]+(!!1+[])[1^1]])[1^1]==+!1)]+(!![]+{})[1|1<<1]+[1+{}+1][!1+!1][(11>>1)+1]](([]+/-/[(!!1+[])[1>>1]+(!!1+[])[1<<1^1]+(!1+[])[1|1<<1]+(!!1+[])[
@SleeplessByte
SleeplessByte / rfc4122-uuid.js
Created April 29, 2014 19:12
RFC4122 compliant UUID in Javascript (by broofa)
'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
@SleeplessByte
SleeplessByte / detect.java
Created November 5, 2014 22:08
Credit Card Detection
public static CardType fromCardNumber( String cardNumber ) {
if ( cardNumber == null )
return CardType.Null;
if ( cardNumber.matches( "^4[0-9]*$" ) )
return CardType.Visa;
if ( cardNumber.matches( "^5[1-5][0-9]*$" ) )
return CardType.MasterCard;
if ( cardNumber.matches( "^3[47][0-9]*$" ))
return CardType.Amex;
if ( cardNumber.matches( "^6(?:011|5)[0-9]*$" ))
Verifying that +sleeplessbyte is my openname (Bitcoin username). https://onename.io/sleeplessbyte
@SleeplessByte
SleeplessByte / view_action.html
Last active August 29, 2015 14:13
View Action Gmail
<div itemscope itemtype="http://schema.org/EmailMessage">
<meta itemprop="description" content="DESCRIPTION"/>
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://evergive.com/redirect_to/posts/organization/xxx/group/yyy"/>
<meta itemprop="name" content="Show community"/>
</div>
<div itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Evergive"/>
<link itemprop="url" href="https://evergive.com"/>
</div>
@SleeplessByte
SleeplessByte / confirm_action.html
Last active August 29, 2015 14:13
Confirm (one-click) Action Gmail
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ConfirmAction">
<meta itemprop="name" content="Approve XXX"/>
<div itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler">
<link itemprop="url" href="https://SOMEURLTOAPPROVE"/>
</div>
</div>
<meta itemprop="description" content="Approval request for John's $10.13 expense for office supplies OR SOMETHING ELSE"/>
</div>
@SleeplessByte
SleeplessByte / save_action.html
Created January 20, 2015 20:07
Save (on-click) Action Gmail
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/SaveAction">
<meta itemprop="name" content="Save Offer"/>
<div itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler">
<link itemprop="url" href="https://offers-everywhere.com/save?offerId=xyz789"/>
</div>
</div>
<meta itemprop="description" content="$5 meal at Joe's Diner"/>
</div>
@SleeplessByte
SleeplessByte / order_extended.html
Created January 20, 2015 20:08
Order / Receipt Gmail
<div itemscope itemtype="http://schema.org/Order">
<div itemprop="merchant" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Amazon.com"/>
</div>
<meta itemprop="orderNumber" content="123-4567890-1234567"/>
<meta itemprop="priceCurrency" content="USD"/>
<meta itemprop="price" content="539.00"/>
<div itemprop="acceptedOffer" itemscope itemtype="http://schema.org/Offer">
<div itemprop="itemOffered" itemscope itemtype="http://schema.org/Product">
<meta itemprop="name" content="Samsung Chromebook"/>
@SleeplessByte
SleeplessByte / timezones
Created February 19, 2015 01:24
Android Timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Asmera
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
@SleeplessByte
SleeplessByte / ListUtils.sortedAdd.java
Created April 2, 2015 19:25
Mainly for use with ArrayList to keep it sorted at insertion time. This method runs in `log(n)` time for a "random access" list (which provides near-constant-time positional access). If the specified list does not implement the `RandomAccess` interface and is large, this method will do an iterator-based binary search that performs `O(n)` link tr…
private static final int NOT_UNIQUE = -1;
/**
* Adds an item in a list using it's comparable sort
*
* @param item the item to add
* @param list the list to add to
* @param uniq if true, reject duplicates
* @param <A> if
* @param <I>