Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
function wait4tcp () {
local nc opt silence op host port ret failed limit tries
local OPTIND OPTARG
limit=100
op="open"
while getopts ":csw:" opt; do
@alain75007
alain75007 / MySingleton.java
Created December 3, 2014 22:22
This class is a singleton class which initializes core objects of Android Volley library
package com.myschool.simpleapp;
import android.content.Context;
import android.graphics.Bitmap;
import android.util.LruCache;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.Volley;
#!/bin/bash
# Simple iptables IP/subnet block script
# Based on works by "nixCraft project" : http://bash.cyberciti.biz/firewall/iptables-block-ip-address/
# -------------------------------------------------------------------------
# Copyright (c) 2014 Alain Beauvoi <http://questioncode.fr/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of questioncode.fr project
# Visit http://questioncode.fr/ for more information.
# ----------------------------------------------------------------------
@alain75007
alain75007 / gist:5518001
Created May 4, 2013 16:28
Monit configuration for sidekiq on debian which complete the init shell you'll find in my gists
check process sidekiq_production with pidfile /var/run/sidekiq_production.pid
depends on redis-server
start program = "/etc/init.d/sidekiq_production start" with timeout 90 seconds
stop program = "/etc/init.d/sidekiq_production stop" with timeout 90 seconds
if totalmem is greater than 200 MB for 2 cycles then restart # eating up memory?
if 2 restarts within 3 cycles then timeout
@alain75007
alain75007 / sidekiq.init.sh
Created May 4, 2013 16:10
sidekiq Launch script on Debian. Change APP "beta" by the environment you want. Important : don't forget to speciy a logfile and a pifile in config/sidekiq.yml of your Rail's app.
#!/bin/bash
### BEGIN INIT INFO
# Provides: sidekiq beta
# Required-Start: $syslog $remote_fs
# Required-Stop: $syslog $remote_fs
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: sidekiq beta - asynchronous rails
@alain75007
alain75007 / ftps.rb
Created January 10, 2012 03:09 — forked from gmgent/ftps.rb
ruby module for using ftps
require 'socket'
require 'openssl'
require 'net/ftp'
class Net::FTPS < Net::FTP
end
class Net::FTPS::Implicit < Net::FTP
FTP_PORT = 990
@alain75007
alain75007 / gist:1533750
Created December 29, 2011 11:59 — forked from dx7/gist:1333785
Installing ruby-debug with ruby-1.9.3-p0
# Install with:
# bash < <(curl -L https://raw.github.com/gist/1333785)
#
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
echo "Installing ruby-debug with ruby-1.9.3-p0 ..."
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
@alain75007
alain75007 / elementToObject
Created October 19, 2011 15:44
Convert element to object then to json
function elementToObject(element, o) {
var el = $(element);
var o = {
tagName: el.tagName
};
var i = 0;
for (i ; i < el.attributes.length; i++) {
o[el.attributes[i].name] = el.attributes[i].value;
}