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

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';

@hanigamal
hanigamal / fine-intersect.cpp
Created September 13, 2013 21:47
Find the point of intersection of two 3D line segments, works in 2D if z=0
// Assume Coord has members x(), y() and z() and supports arithmetic operations
// that is Coord u + Coord v = u.x() + v.x(), u.y() + v.y(), u.z() + v.z()
inline Point
dot(const Coord& u, const Coord& v)
{
return u.x() * v.x() + u.y() * v.y() + u.z() * v.z();
}
inline Point

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';

#!/bin/sh
filename="$1"
extension=${filename##*.}
if [ ${extension} = "doc" ]
then
# Use cat doc for older document formats
catdoc "$filename"
else
codestyle.co examples
@hanigamal
hanigamal / gist:1335186bd90c4e55ad30
Last active August 29, 2015 14:09
Drawing Examples
/*
Draw Rectangles
@include <canvas>
@use fillRect() or fill() or stroke() to render to canvas
*/
function drawRects() {
var ctx = document.getElementById('canvas').getContext('2d');
ctx.fillStyle = "rgb(200,0,0)";
ctx.fillRect(10, 10, 55, 50);
@hanigamal
hanigamal / Stats-animation..markdown
Created January 24, 2015 10:26
Stats animation.

Stats animation.

I loved Virgil's Dribble shot and decided to remake it with some SVG animations :) I didn't really want to recreate the curvy line since I believe straight lines are more accurate. Sorry Virgil, I might make them curvy one day :)! With a bit of time on my hands I could make it even more detailed. I hope you like it and post some feedback on how to make this better :)! Don't forget to check out the original at http://goo.gl/0aKiS0

Kudos Virgil!

Forked from Jonas Badalic's Pen Stats animation..

@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