Skip to content

Instantly share code, notes, and snippets.

@emad-elsaid
emad-elsaid / mysql-backup.rb
Created March 4, 2014 12:40
backup mysql database and send it to your email script
#!/usr/bin/env ruby
require 'mail'
mysql_username = 'root'
mysql_password = '123456'
mysql_database = 'test'
system("mysqldump --user=#{mysql_username} --password=#{mysql_password} #{mysql_database} > backup.sql")
# Credit to :
@emad-elsaid
emad-elsaid / chat.rb
Created March 1, 2014 13:18
creating simple network chat using ruby
require 'sinatra' # gem install sinatra --no-rdoc --no-ri
set :port, 3000
set :environment, :production
html = <<-EOT
<html><head><style>
#text{width:100%; font-size: 15px; padding: 5px; display: block;}
</style></head><body>
<input id="text" placeholder="Write then press Enter."/>
<div id="chat"></div>
@maephisto
maephisto / Javascript ISO country code to country name conversion
Last active November 3, 2023 21:05
ISO 3166-1 alpha-2 country code to country name conversion with a simple Javascript implementation, an array and a function.
var isoCountries = {
'AF' : 'Afghanistan',
'AX' : 'Aland Islands',
'AL' : 'Albania',
'DZ' : 'Algeria',
'AS' : 'American Samoa',
'AD' : 'Andorra',
'AO' : 'Angola',
'AI' : 'Anguilla',
'AQ' : 'Antarctica',
@cristianoc72
cristianoc72 / propel.yaml
Last active March 21, 2022 20:32
Propel sample configuration file
## Sample Propel configuration file ##
propel:
## General settings ##
general:
# The name of your project.
# This affects names of generated files, etc.
project:
version: 2.0.0-dev
@noeticpenguin
noeticpenguin / autolink.js
Created December 13, 2013 18:01
example filter with trust as html for angular 1.2+
@tfnico
tfnico / Something.java
Created July 4, 2013 09:49
Sending a HTTP request with Java + Google Guava
public void sendMessage(String url, String params){
final HttpURLConnection connection;
try {
URL requestUrl = new URL(url);
connection = (HttpURLConnection) requestUrl.openConnection();
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Content-Length", Integer.toString(params.getBytes().length));
connection.setRequestProperty("Content-Language", "en-US");
@adharris
adharris / postgres_array.go
Created November 28, 2012 19:52
PostgreSQL demo of Array types using Golang
package main
import (
"database/sql"
"errors"
"fmt"
_ "github.com/bmizerany/pq"
"os"
"regexp"
"strings"
@gpfeiffer
gpfeiffer / extended_gcd.rb
Last active January 29, 2022 14:16
Extended Euclidean Algorithm in Ruby
#############################################################################
##
## extended_gcd.rb
##
## given non-negative integers a > b, compute
## coefficients s, t such that gcd(a, b) == s*a + t*b
##
def extended_gcd(a, b)
# trivial case first: gcd(a, 0) == 1*a + 0*0
@thom-nic
thom-nic / NumberPickerPreference.java
Created May 6, 2011 22:06
NumberPicker Preference Dialog for Android!
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.TypedArray;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.View;
import com.quietlycoding.android.picker.NumberPicker;
public class NumberPickerPreference extends DialogPreference {