Skip to content

Instantly share code, notes, and snippets.

View sshilko's full-sized avatar

Sergei sshilko

View GitHub Profile
/**
* Read input, line-by-line until get enough lines
*/
var input = [];
var wantlines = 2;
process.stdin.setEncoding('utf8');
var readline = require('readline');
var rl = readline.createInterface({ input: process.stdin });
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@sshilko
sshilko / MYSQLI_ASYNC + autocommit issue
Created May 18, 2015 16:01
mysqli_commit does not work when using mysqlnd + MYSQLI_ASYNC + autocommit=false. The main transaction gets commited, but everything executed via MYSQLI_ASYNC does not get commited.
<?php
/**
* Linux packer-virtualbox-iso 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
* PHP 5.5.19-1+deb.sury.org~precise+1 (cli) (built: Nov 19 2014 19:32:34)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
*/
@sshilko
sshilko / php5523freadtimeout
Last active August 29, 2015 14:18
PHP 5.5.23 breaks TLS (SSL) fread timeout
<?php
$url = 'tls://gateway.sandbox.push.apple.com:2195';
$streamContext = stream_context_create(array('ssl' => array(
'verify_peer' => 1,
'cafile' => './entrust_2048_ca.cer',
'local_cert' => './dev.pem'
)));
@sshilko
sshilko / php-fpm-cli
Last active August 29, 2015 14:09 — forked from muhqu/php-fpm-cli
#!/bin/bash
#
# The MIT License (MIT)
#
# Copyright (c) 2014 Mathias Leppich <mleppich@muhqu.de>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
You appear to be advocating a new:
[ ] cloud-hosted [ ] locally installable [ ] web-based [ ] browser-based [ ] language-agnostic
[ ] language-specific IDE. Your IDE will not succeed. Here is why it will not succeed.
You appear to believe that:
[ ] Syntax highlighting is what makes programming difficult
[ ] Garbage collection is free
[ ] Computers have infinite memory
[ ] Nobody really needs:
#! /usr/bin/env python
import fileinput
import argparse
from operator import itemgetter
parser = argparse.ArgumentParser()
parser.add_argument('--target-mb', action = 'store', dest = 'target_mb', default = 61000, type = int)
parser.add_argument('vmtouch_output_file', action = 'store', nargs = '+')
args = parser.parse_args()
# Username/password example
# DAEMON_ARGS="-b -t -a \"*.*.*.*\" -e /var/log/transmission/transmission.log"
# No username/password, but limited to 192.168.1.*
# DAEMON_ARGS="-b -T -a \"192.168.1.*\" -e /var/log/transmission/transmission.log"
INTERFACE=ppp0
if ifconfig $INTERFACE >>/dev/null 2>&1; then
BIND_ADDR="`/sbin/ifconfig $INTERFACE | awk '$1 == \"inet\" {print $2}' | awk -F: '{print $2}'`"
How to crack Sublime Text (2 and 3)
===
1. Open Sublime in a HEX editor (the executable file)
2. Find 43 33 33 42 30 32
3. Replace in the string above 33 42 with 32 42
4. Save
5. Enter the license below:
—–BEGIN LICENSE—–
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>App Redirection</title>
</head>
<body>
<!-- iframe used for attempting to load a custom protocol -->
<iframe style="display:none" height="0" width="0" id="loader"></iframe>