Skip to content

Instantly share code, notes, and snippets.

View keyle's full-sized avatar
👹

keyle

👹
View GitHub Profile
@keyle
keyle / simpleajax
Created March 14, 2014 08:35
Simple ajax, pure javascript, no jquery
function callAjax(url, callback){
var xmlhttp;
// compatible with IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4 && xmlhttp.status == 200){
callback(xmlhttp.responseText);
}
}
xmlhttp.open("GET", url, true);
@keyle
keyle / oojs.js
Last active August 29, 2015 13:57
object oriented javascript a la typescript
var App = (function () {
function App() {
console.log("App constructor");
}
App.prototype.init = function () { // poluting the prototype => instance method
console.log("app.init() is instance init \n" + this);
};
/// <reference path="phaser.d.ts" />
declare var require;
var game:Phaser.Game;
var cursors:Phaser.CursorKeys;
var flipperLeft:endice.Flipper;
var flipperRight:endice.Flipper;
var ball:endice.Ball;
@keyle
keyle / webql2 def
Last active August 29, 2015 13:58
webql2
keywords
from <url|rss|google|ddg>
select <jqueryStyleSelector>
where <attr.name|value> <contains|!contains|match> <string|regexp>
limit <num>
skip <num>
reverse
shuffle
first
@keyle
keyle / webql2.1
Last active August 29, 2015 13:59
webql2.1
webql
from <url|google|ddg>
show <links|text|html|rss>
where? <condition>
to? <screen|csv|json|xml|rss|table>
from google search "key words here"
open 5
display links
@keyle
keyle / HDD.groovy
Created August 4, 2014 10:34
Groovy. Write objects to file (json) and read them back
package utils
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
class HDD {
static save(Object content, String filePath) {
new File(filePath).write(new JsonBuilder(content).toPrettyString())
}
def WITHIN_TRADE_PERIOD = minuteFromStart > 5 && minuteFromStart < 15
def RANGE_IS_SUDDEN = G.RANGE_NOW > 25 && G.RANGE_MIN1 < 15 && G.RANGE_MIN1 < 15
def PRICE_IS_GOING = price > 70 || price < 30
if (WITHIN_TRADE_PERIOD) {
println "potential trade..."
if (RANGE_IS_SUDDEN) {
@keyle
keyle / Hash.groovy
Created August 15, 2014 13:33
String MD5 hash
package utils
import java.security.MessageDigest
class Hash {
static String md5(String s) {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(s.getBytes());
BigInteger hash = new BigInteger(1, md5.digest());
@keyle
keyle / parsleysetup.as
Last active August 29, 2015 14:05
Parsley 3.0 in AS3 only
package
{
public class Model
{
public var test:Array = ["hello", "world"];
}
public class Player
{
[Inject]
@keyle
keyle / parsleySetup2.as
Last active August 29, 2015 14:05
Parsley 3.0 in AS3 only - NO XML
package
{
import org.spicefactory.parsley.context.ContextBuilder;
import org.spicefactory.parsley.core.context.Context;
public class ParsleyContext
{
public static var context:Context;
public static function init():void