Skip to content

Instantly share code, notes, and snippets.

View javajosh's full-sized avatar

javajosh javajosh

View GitHub Profile
<snippet>
<content><![CDATA[
blah blah
]]></content>
<!-- Optional: Tab trigger to activate the snippet -->
<tabTrigger>html5</tabTrigger>
<!-- Optional: Scope the tab trigger will be active in -->
<scope>source.html</scope>
<!-- Optional: Description to show in the menu -->
<description>My Fancy HTML snippet</description>
[{"name": "foo"},{"name": "bar"}]
@javajosh
javajosh / gist:3c83cd66922ef27a0431
Created February 2, 2015 18:30
How to Tab out of a closed quote in Sublime text
{ "keys": ["tab"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "following_text", "operator": "regex_contains", "operand": "^[)'\"\\]]", "match_all": true },
{ "key": "auto_complete_visible", "operator": "equal", "operand": false }
]
}
@javajosh
javajosh / Lamda1
Last active August 29, 2015 14:21
final List<Integer> numbers = Arrays.asList(1,2,3,4,5,6,6);
Set<Integer> unique = numbers
.stream()
.map(x -> x * x)
.filter(x -> x < 10)
.collect(Collectors.toSet());
@javajosh
javajosh / Foo.class
Last active August 29, 2015 14:21
Java Lambdas and The Case of the Missing imul
//javap -c -p Foo.class
Compiled from "Foo.java"
class Foo {
Foo();
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
public static void main(java.lang.String[]);
@javajosh
javajosh / redemption.js
Created May 28, 2015 23:03
A fancy deletion
function makeList(n){
var head = {'i':0};
var prev = head;
var current;
for (var i = 1; i < n; i++) {
current = {'i': i};
prev.next = current;
prev = current;
};
public Main{
public static void main(String[] args){
System.out.print1n("Yo Wassup World");
}
}
/**
*
* Ray Tayek needs function that escapes all regular expression characters in a string.
*/
public class RegexEscape {
private static char[] reserved="$()*+-.?[\\]^{|}".toCharArray();
//the toCharArray() way
public static String encode(String arg){
char[] source = arg.toCharArray();
String s = "<SCRIPT type=\"blah\" .....>xyz" +
"blah blah blah blah\n" +
"blah blah blah blah\n" +
"blah blah ...........\n" +
"</script>";
Pattern p = Pattern.compile("<script .*?(>.*?)</script>",
Pattern.DOTALL | Pattern.CASE_INSENSITIVE);
Matcher m = p.matcher(s);
if (m.matches()) {
package com.javajosh.bender.server;
import com.javajosh.bender.client.GreetingService;
import com.javajosh.bender.client.GreetingServiceAsync;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/**
* The server side implementation of the RPC service.