Skip to content

Instantly share code, notes, and snippets.

View hanigamal's full-sized avatar
🎯
Focusing at office

Hani Gamal hanigamal

🎯
Focusing at office
View GitHub Profile
@hanigamal
hanigamal / S3_regex.pl
Created June 11, 2012 17:03
Parse S3 log files using Perl regular expressions
#!/usr/bin/perl -w
use strict;
while (my $line=<>) {
my ($date, $host, $url_with_method, $status, $size, $referrer, $agent) = $line =~
m/^\S+\s+\S+\s+\[(\S+\s+[\-|\+]\d{4})\]\s+(\S+)\s+\S+\s+\S+\s+\S+\s+\S+\s+"(\S+\s+\S+\s+[^"]+)"\s+(\d{3})\s+\S+\s+(\d+|-)\s+\d+\s+\d+\s+\d+\s+"(.*?)"\s+"(.*?)"/;
# Print relevant bits
}
import android.accounts.Account;
import android.accounts.AccountManager;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Build;
import android.preference.PreferenceManager;
public final class AccountUtils {
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
// Generated on: 2012-04-13 23:44:46 GMT+00:00
// ************** Tweet 1 of 47455 **************
{
"in_reply_to_screen_name": null,
#!/bin/sh
SHORTCUT="[Desktop Entry]
Name=Sublime Text 2
Comment=Edit text files
Exec=/usr/local/sublime-text-2/sublime_text
Icon=/usr/local/sublime-text-2/Icon/128x128/sublime_text.png
Terminal=false
Type=Application
Encoding=UTF-8
Categories=Utility;TextEditor;"

Conventions:

Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):

class Shop extends Eloquent {}

Using custom table name

protected $table = 'my_shops';

Conventions:

Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):

class Shop extends Eloquent {}

Using custom table name

protected $table = 'my_shops';

codestyle.co examples
@hanigamal
hanigamal / remove_empty_value.js
Last active August 29, 2015 14:27 — forked from nuwansh/remove_empty_value.js
Remove empty elements from an array in Javascript and join it as string
/**This is example works with only jQuery
* @usecase, if you have an array with empty values (ex: ["I", "", "want", "", "to", "go", "" ])
* but you want to return this array as a string.
*/
var myRoom = {
myAction: function(array){
garray = $.grep(array,function(n){
return(n);
});
@hanigamal
hanigamal / snaptoroad.js
Last active February 25, 2019 14:54 — forked from omkz/snaptoroad.js
google maps API javascript v3 - polyline snap to road
var directionsService = new google.maps.DirectionsService();
directionsService.route(request, function (response, status) {
if (status == google.maps.DirectionsStatus.OK) {
var polyline = new google.maps.Polyline(polylineOptions);
var path = response.routes[0].overview_path;
for (var x in path) {
@hanigamal
hanigamal / clean-raspberry.sh
Created October 10, 2015 01:06 — forked from bivald/clean-raspberry.sh
Clean Raspberry Pi Debian
#!/bin/bash
sudo apt-get --yes purge xserver* x11-common x11-utils x11-xkb-utils x11-xserver-utils xarchiver xauth xkb-data console-setup xinit lightdm libx{composite,cb,cursor,damage,dmcp,ext,font,ft,i,inerama,kbfile,klavier,mu,pm,randr,render,res,t,xf86}* lxde* lx{input,menu-data,panel,polkit,randr,session,session-edit,shortcut,task,terminal} obconf openbox gtk* libgtk* alsa* nano python-pygame python-tk python3-tk scratch tsconf
sudo apt-get -y purge aspell hunspell-en-us iptraf libaspell15 libhunspell-1.2-0 lxde lxsession lxtask lxterminal squeak-vm whiptail zenity gdm gnome-themes-standard python-pygame
apt-get --yes purge xdg-tools desktop-file-utils omxplayer python3-numpy python3
sudo apt-get remove xserver-xorg
sudo apt-get purge ^lx
sudo apt-get --yes autoremove
sudo apt-get --yes autoclean
sudo apt-get --yes clean