Skip to content

Instantly share code, notes, and snippets.

View infynyxx's full-sized avatar
🫐

Prajwal Tuladhar infynyxx

🫐
View GitHub Profile
@infynyxx
infynyxx / MobileStreamRequest.php
Created July 23, 2009 18:03
Example of Template Pattern
<?php
abstract class MobileStreamsReqest {
private $_username;
private $_password;
private $_URI;
private $_version;
protected $parameters = array();
protected $requestAttrbutes = array();
protected $requestString;
@infynyxx
infynyxx / custom_event.js
Created July 23, 2009 18:11
JS custom event handling based on PrototypeJS
//Custom Event handling
Event.observe(document, 'dom:loaded', function() {
$('enableInputEvents').observe('click', function(e) {
document.fire('CheckBox:Enabled', {checked: $('enableInputEvents').checked});
});
});
document.observe('CheckBox:Enabled', function(e) {
Event.stop(e);
if (e.memo.checked) {
function addGenerator(num) {
return function(toAdd) {
return num + toAdd;
}
}
var addFive = addGenerator(5);
console.log(addFive(4) == 9);
@infynyxx
infynyxx / anonymous.php
Created August 20, 2009 14:26
lambda in PHP
<?php
$lambda = function($time) {
echo "I am an anonymous function and being called {$times} times<br/>";
};
function nCallTo($n, Closure $function) {
for ($i = 0; $i < $n; $i++) {
$function($i+1);
}
return function() {
<?php
class ConsignmentClient extends SoapClient {
public function __construct($wsdl, $options) {
parent::__construct($wsdl, $options);
}
}
class Consignment {
@infynyxx
infynyxx / twitter_client_reader_node.js
Created November 29, 2009 04:48
dead simple Twitter client based on Node.js
/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
*
**/
var Base64 = {
@infynyxx
infynyxx / buffer-conf.conf
Created January 4, 2010 18:41
Scribe Buffer Configuration
port=1463
max_msg_per_second=2000000
check_interval=3
new_thread_per_category=no
<store>
type=buffer
category=stats*
max_queue_length=10
buffer_send_rate=1
db.runCommand({movechunk: "test.people", find: {name: "XYZ0"}, to: "127.0.0.1:10000"});
db.runCommand({split: "test.people", middle: {name: "XYZ0"}});
@infynyxx
infynyxx / preforking.c
Created February 7, 2010 08:09
Simple preforking server
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
int main(int argc, char *argv[]) {
struct sockaddr_in addr;
int listenSocket, newSocket;
char buffer[25];
@infynyxx
infynyxx / enumerate.py
Created February 21, 2010 10:08
python enumeration
#this is more clearer than below code
for i,n in enumerate(x):
if x[i] < 0:
print "Found negative nunber @ index ", i