Skip to content

Instantly share code, notes, and snippets.

@falsecz
falsecz / gist:1050760
Created June 28, 2011 08:48
Order by numbers first cs_CZ
CREATE OR REPLACE FUNCTION order_numbers_first(string character varying)
RETURNS character varying AS
$BODY$
DECLARE new_string character varying;
c character varying;
i integer;
BEGIN
i := 0;
new_string := '';
<?php
/**
* @method string metoda($param) Komentar
*/
class A { }
namespace NS;
/**
@falsecz
falsecz / gist:1675582
Created January 25, 2012 09:18
Node.JS php exec
// /usr/local/src/httpd-2.3.16-beta/support/ab -r -n 10000 -c 10 http://127.0.0.1:1327/
var http = require('http');
var sys = require('util')
var exec = require('child_process').exec;
var util = require('util');
var cnt = 0;
data = networks: [
type: "facebook"
message: "Dlouha zprava pro fejskuuuuuk"
profiles: [
id: "2431233"
name: "Moje pejdz"
selected: true
,
id: "242342343"
name: "Jina pejdz"
@falsecz
falsecz / gist:2044054
Created March 15, 2012 12:53
Formatovani entities v tweetu
formatTweet: (tweet) ->
chars = []
text = tweet.text
chars.push c for c in tweet.text
chars = @processEntity chars, tweet.entities.hashtags, (entity) ->
'<a href="#">#' + entity.text + '</a>'
chars = @processEntity chars, tweet.entities.user_mentions, (entity) ->
'<a href="#">@' + entity.screen_name + '</a>'
chars = @processEntity chars, tweet.entities.urls, (entity) ->
@falsecz
falsecz / gist:2874628
Created June 5, 2012 12:10
Underscore CamelCase PascalCase
protected function underScoreToCamelCase( $string ) {
return preg_replace( '/(?:^|_)(.?)/e', "strtoupper('$1')", $string );
}
protected function underScoreToPamelCase( $string ) {
return preg_replace( '/_(.?)/e', "strtoupper('$1')", $string );
}
TokenPool = require '../index'
tp = new TokenPool
describe "Sample test", ->
it "melo by to delat to a to", ->
tp.get (data)->
expect(data).toEqual 'data z poolu'
it "to by melo spadnout", ->
tp.get (data)->
mp = require 'msgpack3'
string = '{"_index":"posts-2012-29","_type":"post","_id":"438861426136421_439222532766977","_version":7,"exists":true, "_source" : {"id":"438861426136421_439222532766977","message":"z fejsu","picture":"http:\/\/photos-e.ak.fbcdn.net\/hphotos-ak-ash3\/524088_439222509433646_1975878462_s.jpg","link":"http:\/\/www.facebook.com\/photo.php?fbid=439222509433646&set=a.439222506100313.96281.438861426136421&type=1&relevant_count=1","icon":"http:\/\/static.ak.fbcdn.net\/rsrc.php\/v2\/yz\/r\/StEh3RhPvjk.gif","actions":[{"name":"Comment","link":"http:\/\/www.facebook.com\/438861426136421\/posts\/439222532766977"},{"name":"Like","link":"http:\/\/www.facebook.com\/438861426136421\/posts\/439222532766977"}],"privacy":{"description":"Public","value":"EVERYONE"},"type":"photo","object_id":"439222509433646","created_time":"2012-07-18T15:56:31+00:00","updated_time":"2012-07-18T16:02:18+00:00","comments":{"438861426136421_439222532766977_1139378":1342627338},"like_count":0,"comment_count":1,"first_admin_
@falsecz
falsecz / gist:3324475
Created August 11, 2012 13:35
Bash over socket
server = net.createServer (socket) ->
term = pty.spawn 'bash', [], {
name: 'xterm-color',
cols: 80,
rows: 30,
cwd: process.env.HOME,
env: process.env
}
term.on 'data', (data) ->
http = require 'http'
util = require 'util'
net = require 'net'
command = process.argv.splice 2
options =
host: '10.1.69.105'
port: 80
path: '/'