Skip to content

Instantly share code, notes, and snippets.

@ruckuus
ruckuus / Directory_Pair_To_Store_File_Size.sh
Last active August 29, 2015 14:05
Directory_Pair_To_Store_File_Size
#!/usr/bin/env bash
[[ -z $1 ]] && echo "Please provide source directory" && exit -1
SOURCE=$1
DSTDIR=${SOURCE}.size
FILES=$(find $SOURCE -type f -not -user root -print | tr "\n" ",")
gen_file_size() {
SRCFILE="$1"
@ruckuus
ruckuus / Dockerfile
Created April 16, 2014 17:17
Create casperjs docker image
FROM ubuntu
RUN apt-get update
RUN apt-get install -y git-core curl libfreetype6 libfontconfig
RUN curl -LO https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.7-linux-x86_64.tar.bz2
RUN tar xjfv phantomjs-1.9.7-linux-x86_64.tar.bz2 -C /usr/local/
RUN ln -sf /usr/local/phantomjs-1.9.7-linux-x86_64/bin/phantomjs /usr/local/bin/phantomjs
RUN git clone https://github.com/n1k0/casperjs.git /usr/local/casperjs
RUN ln -sf /usr/local/casperjs/bin/casperjs /usr/local/bin/casperjs
RUN rm -f phantomjs-1.9.7-linux-x86_64.tar.bz2
@ruckuus
ruckuus / twitter.js
Created March 26, 2014 17:20
Automate JS
var cs = require("casper").create({
verbose: true,
logLevel: 'debug'
});
myUsername = cs.cli.has("username") ? cs.cli.get("username") : "";
myPassword = cs.cli.has("password") ? cs.cli.get("password") : "";
cs.start("https://twitter.com", function() {
if (this.exists('div.front-signin.js-front-signin')) {
<?php
class Numlet{
protected $fizz = false;
protected $buzz = false;
public function isFizz($n) {
if ($n % 3 == 0) {
$this->fizz = true;
return true;
@ruckuus
ruckuus / PHP Redis Client Test [Predis vs phpredis]
Last active February 13, 2019 13:22
PHP Redis Client Test [Predis vs phpredis]
php redisTest.php
Keyword: free+book, score:736764
Keyword: pretty+picture, score:117600
Keyword: best+seller, score:411600
Keyword: stuff, score:2998800
Keyword: bedok, score:29400
Keyword: best+seller+free+book, score:176400
Keyword: best+seller, score:411600
Keyword: best+seller, score:411600
Keyword: free+book, score:736764
@ruckuus
ruckuus / lolbackup.sh
Created July 4, 2013 09:59
simple backup script
#!/bin/bash
TO=/path/to/backups
FROM=/home/foo/webroot/awesome_website
now=`date +"%F"`
NUM_TO_KEEP=3 # How many artefacts do you want to keep
[ -e /$TO/$now/backup_yes ] && echo "Already backup today" && exit 0
cd $TO
export NUM_TOTAL=`find . -maxdepth 1 -type d | grep '^./' | wc -l`
export NUM_TO_DEL=`expr $NUM_TOTAL - $NUM_TO_KEEP`
casper.evaluate(function triggerKeyDownEvent() {
var e = jQuery.Event("keydown");
e.which = 13;
e.keyCode = 13;
jQuery("#questions_holder .question:nth-child(1) .txt-inline-answer").trigger(e);
});
@ruckuus
ruckuus / LoginControllerProvider.php
Last active July 9, 2017 20:46
Silex User Authentication and PHP ActiveRecord
<?php
/*
* Put it in App/Provider
*/
namespace App\Provider;
use Silex\Application;
use Silex\ControllerProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@ruckuus
ruckuus / ActiveRecordServiceProvider.php
Last active December 17, 2015 00:09
Autoload PHPActiveRecord to work with Silex
<?php
/*
* Author: Dwi Sasongko S <ruckuus@gmail.com>
* See: http://www.phpactiverecord.org/projects/main/wiki/Quick_Start
*/
namespace App\Provider;
use Silex\Application;
@ruckuus
ruckuus / install_python.sh
Created July 11, 2012 07:46 — forked from jgumbley/install_python.sh
setup python 2.7.1 on CENTOS 5.* server
# wget -O install_python.sh https://gist.github.com/raw/777001/install_python.sh
# chmod +x install_python.sh
# ./install_python.sh
#!/bin/sh
echo "******************************************"
echo "Configure Centos box with a recent version"
echo "of Python. "
echo " - jgumbley 12/jan/11"