Skip to content

Instantly share code, notes, and snippets.

View fullofcaffeine's full-sized avatar

Marcelo Serpa fullofcaffeine

View GitHub Profile
@nuxlli
nuxlli / unix_socket_request.sh
Last active January 25, 2024 04:37
Examples of http request in unix domain socket with shell, using socat, netcat or curl
#!/bin/bash
# References
# http://www.computerhope.com/unix/nc.htm#03
# https://github.com/daniloegea/netcat
# http://unix.stackexchange.com/questions/26715/how-can-i-communicate-with-a-unix-domain-socket-via-the-shell-on-debian-squeeze
# http://unix.stackexchange.com/questions/33924/write-inside-a-socket-open-by-another-process-in-linux/33982#33982
# http://www.linuxjournal.com/content/more-using-bashs-built-devtcp-file-tcpip
# http://www.dest-unreach.org/socat/
# http://stuff.mit.edu/afs/sipb/machine/penguin-lust/src/socat-1.7.1.2/EXAMPLES
@hashrock
hashrock / Perm.hx
Created September 4, 2013 08:19
Permutation in Haxe
class Perm {
//最終的に返すもの(組み合わせのパターン)
private var patterns:Array<Array<Int>>;
//入力数字列
private var in_ary:Array<Int>;
/**
* コンストラクタ
* @param in_ary 入力数字列
*/
@charleslouis
charleslouis / bem-cheat-sheet.txt
Created June 5, 2013 11:24
CSS - BEM - Cheat Sheet
For more details, see :
SMACCS and Fifty Shades of BEM (http://blog.kaelig.fr/post/48196348743/fifty-shades-of-bem)
prefix-ComponentName
prefix-ComponentName-MODIFIERNAME
prefix-ComponentName-subObject
prefix-ComponentName-subObject-MODIFIERNAME
p- Page specific (class applied on the body element), very useful for static pages where maintainability is not at stake — should be avoided in the application itself (e.g.: p-Homepage).
@puffnfresh
puffnfresh / Example.hx
Last active March 6, 2020 01:09
Macro to generate "value classes" in Haxe
import precog.macro.ValueClass;
class ABC implements ValueClass {
var a: Int;
var b: Bool;
var c: String;
}
/*
class ABC extends ValueClass {
package ;
abstract JsonMap<T>({ }) from {} {
public function new() this = {};
public function exists(key:String) return Reflect.hasField(this, key);
@:arrayAccess public function get(key:String) return Reflect.field(this, key);
@:arrayAccess public function set(key:String, value:T):T {
Reflect.setField(this, key, value);
return value;
}
@tong
tong / NekoBoot.hx
Last active January 27, 2020 11:49
Haxe port of nekoboot.neko for creating executables from bytecode. Original: http://code.google.com/p/nekovm/source/browse/trunk/src/tools/nekoboot.neko Usage : nekoboot <file.n>
import sys.FileSystem;
import sys.io.File;
/**
Haxe port of nekoboot.neko for creating executables from neko bytecode.
Original version: https://github.com/HaxeFoundation/neko/blob/master/src/tools/nekoboot.neko
Usage : nekoboot <file.n>
*/
@sj26
sj26 / assets.rake
Last active May 13, 2023 04:42
Don't discard cache during asset precompile. Full explanation and caveats: http://sj26.com/2013/02/09/the-asset-pipeline-isnt-actually-slow
# Stick this in lib/tasks/assets.rake or similar
#
# A bug was introduced in rails in 7f1a666d causing the whole application cache
# to be cleared everytime a precompile is run, but it is not neccesary and just
# slows down precompiling.
#
# Secondary consequences are the clearing of the whole cache, which if using
# the default file cache could cause an application level performance hit.
#
# This is already fixed in sprockets-rails for rails 4, but we patch here for
@back2dos
back2dos / Main.hx
Last active December 10, 2015 22:28
Hello world with tinx_node
package ;
class Main implements tink.lang.Cls {
static function main()
@with(tinx.node.Http.server(2000))
@on(request)
request.respond().end('hello world')
}
@embray
embray / suggest_backports.py
Last active July 26, 2019 11:41
List pull requests merged since the last tag on the given release branch which have not yet been merged into the release branch.
#!/usr/bin/env python
# I wasn't happy with any of the GitHub libraries for Python that I tried so I
# just used the GitHub API directly. If someone would like to rewrite this
# using a library please be my guest
from __future__ import unicode_literals
import argparse
import base64
@ryanb
ryanb / issues_with_modules.md
Created November 29, 2012 22:38
Points on how modules can make code difficult to read.

My issues with Modules

In researching topics for RailsCasts I often read code in Rails and other gems. This is a great exercise to do. Not only will you pick up some coding tips, but it can help you better understand what makes code readable.

A common practice to organize code in gems is to divide it into modules. When this is done extensively I find it becomes very difficult to read. Before I explain further, a quick detour on instance_eval.

You can find instance_eval used in many DSLs: from routes to state machines. Here's an example from Thinking Sphinx.

class Article &lt; ActiveRecord::Base