Skip to content

Instantly share code, notes, and snippets.

View tagrudev's full-sized avatar

Todor Grudev tagrudev

View GitHub Profile
1.9.3p194 :001 > [1,2,3,4,5,6].in_groups(4,false)
=> [[1, 2], [3, 4], [5], [6]]
product = Product.new
product.name = "Hello"
product.save!
/**
* Mulit-byte Unserialize
*
* UTF-8 will screw up a serialized string
*
* @access private
* @param string
* @return string
*/
function mb_unserialize($string) {
1.9.3-p194 :001 > a = [1, 2, 3, 4]
=> [1, 2, 3, 4]
1.9.3-p194 :002 > a.last
=> 4
1.9.3-p194 :003 >
// Making HTTP request
try {
// defaultHttpClient
HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
DefaultHttpClient client = new DefaultHttpClient();
SchemeRegistry registry = new SchemeRegistry();
public void onCreate() {
Toast.makeText(getApplicationContext(), "service created", Toast.LENGTH_SHORT).show();
try {
this.socket = new SocketIO("https://mysocketserver");
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null, null, null);
SocketIO.setDefaultSSLSocketFactory(sc);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
09-12 14:55:52.501: W/System.err(29546): Catch exception while startHandshake: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x2c1428: Failure in SSL library, usually a protocol error
09-12 14:55:52.501: W/System.err(29546): error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:683 0xad127597:0x00000000)
tagrudev:socket.io-java-client/ (master) $ ant jar [10:08:32]
Buildfile: /home/tagrudev/Code/socket.io-java-client/build.xml
init:
build-project:
[echo] socket.io-java-client: /home/tagrudev/Code/socket.io-java-client/build.xml
[javac] /home/tagrudev/Code/socket.io-java-client/build.xml:40: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 9 source files to /home/tagrudev/Code/socket.io-java-client/bin
@tagrudev
tagrudev / gist:3698101
Created September 11, 2012 12:35
socket.io
tagrudev:socket.io-java-client/ (master) $ sudo ant jar [15:33:26]
Buildfile: /home/tagrudev/Code/socket.io-java-client/build.xml
init:
build-project:
[echo] socket.io-java-client: /home/tagrudev/Code/socket.io-java-client/build.xml
[javac] /home/tagrudev/Code/socket.io-java-client/build.xml:40: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 9 source files to /home/tagrudev/Code/socket.io-java-client/bin
[javac] /home/tagrudev/Code/socket.io-java-client/src/io/socket/WebsocketTransport.java:11: package org.java_websocket.client does not exist
@tagrudev
tagrudev / gist:2970755
Created June 22, 2012 06:20
Installing working ruby + rails env on 12.04
Ubuntu 12.04 Ruby on Rails Development Environment
I haven't set up an install guide for the latest ubuntu release, largely because the last set of instructions worked pretty closely with the latest and greatest Ubuntu, 12.04 Precise Pangolin, however when installing today, I found that there were enough differences in the way that I configure my setup to justify an update, so here it goes. Yes, I'm late to the party, but a quick google search didn't find anything that I felt was as complete for my requirements as my previous install guides, so here I go.
As always with my install guides, I have included here is just about everything you'll need (and then some) to get started with ruby on rails development with Ubuntu 12.04 as a platform. These are my settings and preferences, and this is certainly not the only way of doing things, so keep that in mind.
Step 1: Get the repos ready and run updates.
sudo apt-get update && sudo apt-get upgrade