Skip to content

Instantly share code, notes, and snippets.

View endel's full-sized avatar

Endel Dreyer endel

View GitHub Profile
var socket = new WebSocket('ws://127.0.0.1:8889');
socket.onopen = function ( ) {
console.log('connection is opened');
return;
};
socket.onmessage = function ( msg ) {
console.log(msg.data);
return;
};
@endel
endel / arrays.php
Created July 3, 2014 20:14
PHP: remove and return key from array
<?php
$name = $attribute['name'];
unset($attribute['name']);
$type = camel_case($attribute['type']);
unset($attribute['type']);
$index = null;
if (isset($attribute['index'])) {
$index = $attribute['index'];
// From: http://stackoverflow.com/questions/61552/are-there-legitimate-uses-for-javascripts-with-statement
for (var i=0; i<3; ++i)
{
// object members introduced in this statement
// are scoped to the block following it.
with ({num: i})
{
setTimeout(function() { alert(num); }, 10);
}
@endel
endel / build.json
Last active August 29, 2015 14:10
Game Engine JSON Structure.
{
"resources": {
"game" : [
{ "id": "players", "url": "assets/tp/players.json" },
{ "id": "level", "url": "assets/tilemaps/test.json", "type": "tilemap" }
],
},
"scenes": {
"scene-1": { "url": "assets/scene-1.json" }
}
@endel
endel / Example-1.swift
Created January 18, 2015 14:00
Alamofire + SwiftyJSON = Segmentation fault?
// Just instantiating is fine, the request gets executed normally
var req : MyRequest = MyRequest(...);
@endel
endel / convert.rb
Last active August 29, 2015 14:19
RPG Maker Sprite-Sheet extractor. It generates a separate .png file for each sprite.
# RPG Maker sprite-sheet extractor
require 'fileutils'
target_file = File.basename(ARGV[0], File.extname(ARGV[0]))
output_dir = "#{File.dirname(ARGV[0])}/#{target_file}"
FileUtils.mkdir_p(output_dir)
# extract each sprite
%x(convert #{ARGV[0]} -crop 24x32 #{output_dir}/sprite-%03d.png)
@endel
endel / gist:39a53f5fa4370f76d872
Last active August 29, 2015 14:22
hook installation output
[ 1:45:24] endel:~/Projects
$ curl -sSL https://raw.githubusercontent.com/doubleleft/hook/master/scripts/install.sh | bash
Cloning into 'hook'...
remote: Counting objects: 248, done.
remote: Compressing objects: 100% (219/219), done.
remote: Total 248 (delta 9), reused 120 (delta 6), pack-reused 0
Receiving objects: 100% (248/248), 155.39 KiB | 0 bytes/s, done.
Resolving deltas: 100% (9/9), done.
Checking connectivity... done.
# check dependencies
@endel
endel / Magento: Retorno de pagamento do PagSeguro
Created April 7, 2010 21:27
Retorno do PagSeguro customizado. Veja o módulo completo em: http://visie.com.br/pagseguro/plataforma/magento/
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
@endel
endel / gist:434481
Created June 11, 2010 13:39
J2ME Bitmap Font Class
package com.stonespells.core;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class Font {
// additional space between characters
public int charS = 0;
// max clipping area
require 'ar-extensions'
# ActiveRecord::Extensions fix for using ILIKE with PostgreSQL database
#
# Usage sample:
# User.find(:all, :conditions { :name_ilike => "%something%" })
module ActiveRecord::Extensions
class ILike