Skip to content

Instantly share code, notes, and snippets.

View feelinc's full-sized avatar
🏠
Working from home

Sulaeman feelinc

🏠
Working from home
View GitHub Profile
var http = require('http');
var server = http.createServer(function(req, res) {
// console.log(req); // debug dump the request
// If they pass in a basic auth credential it'll be in a header called "Authorization" (note NodeJS lowercases the names of headers in its request object)
var auth = req.headers['authorization']; // auth is in base64(username:password) so we need to decode the base64
console.log("Authorization Header is: ", auth);
<?php
return Response::json(new SettingTemplate($data));
<?php
class SomeClass
{
/**
* Hold options data for later use.
*
* @var Array
*/
@feelinc
feelinc / aname-async.js
Last active August 29, 2015 14:02
REST API Resource Template Data
/**
* Module dependencies.
*/
var async = require('async')
, countryTemplate = require('./country')
, _ = require('underscore');
function aname(models, model, options, callback) {
if ( ! _.isObject(model)) {
if (typeof callback != 'undefined') {
@feelinc
feelinc / UploadDirDropbox.py
Created June 30, 2015 05:35
Upload folder content to Dropbox
#!/usr/bin/python
import os
import sys
from dropbox.client import DropboxClient
# get an access token, local (from) directory, and Dropbox (to) directory
# from the command-line
access_token, local_directory, dropbox_destination = sys.argv[1:4]
@feelinc
feelinc / Translator.php
Created September 17, 2015 10:23
Translation class similar to Gettext usage approach
<?php
use Symfony\Component\Translation\Translator as SymfonyTranslator;
use Symfony\Component\Translation\MessageSelector;
use Symfony\Component\Translation\Loader\PhpFileLoader;
class Translator
{
/**
<?php
/**
* UUID class
*
* The following class generates VALID RFC 4211 COMPLIANT
* Universally Unique IDentifiers (UUID) version 3, 4 and 5.
*
* UUIDs generated validates using OSSP UUID Tool, and output
* for named-based UUIDs are exactly the same. This is a pure
* PHP implementation.
<?php
/*
DrUUID RFC4122 library for PHP5
by J. King (http://jkingweb.ca/)
Licensed under MIT license
See http://jkingweb.ca/code/php/lib.uuid/
for documentation
Last revised 2011-03-20
@feelinc
feelinc / paddleball.py
Created April 13, 2013 16:13
Bounce game, using Python 3 & Tkinter
from tkinter import *
import random
import time
class Ball:
def __init__(self, canvas, paddle, color):
self.canvas = canvas
self.paddle = paddle
self.id = canvas.create_oval(10, 10, 25, 25, fill=color)
<?php
namespace Assetic\Filter;
use Assetic\Asset\AssetInterface;
use Assetic\Util\ProcessBuilder;
/**
* Runs assets through gzip.
*/