Skip to content

Instantly share code, notes, and snippets.

View mrf345's full-sized avatar

Mohamed Feddad mrf345

  • UAE
View GitHub Profile
@jimeh
jimeh / .gitignore
Created December 24, 2009 11:51
A quick head-to-head performance test of JSON vs. BSON.
.DS_Store
data.rb
results.txt
@louisbullock
louisbullock / dabblet.css
Created July 16, 2012 04:31
Wooden Wall [CSS]
/* Wooden Wall [CSS] */
/* Made with ♥ by Louis Bullock */
html,body {
height: 100%;
overflow: hidden;
}
html {
display:block;
@Goles
Goles / CountryCodes.json
Created July 29, 2012 05:37
Country and Dial or Phone codes in JSON format
[{"name":"Israel","dial_code":"+972","code":"IL"},{"name":"Afghanistan","dial_code":"+93","code":"AF"},{"name":"Albania","dial_code":"+355","code":"AL"},{"name":"Algeria","dial_code":"+213","code":"DZ"},{"name":"AmericanSamoa","dial_code":"+1 684","code":"AS"},{"name":"Andorra","dial_code":"+376","code":"AD"},{"name":"Angola","dial_code":"+244","code":"AO"},{"name":"Anguilla","dial_code":"+1 264","code":"AI"},{"name":"Antigua and Barbuda","dial_code":"+1268","code":"AG"},{"name":"Argentina","dial_code":"+54","code":"AR"},{"name":"Armenia","dial_code":"+374","code":"AM"},{"name":"Aruba","dial_code":"+297","code":"AW"},{"name":"Australia","dial_code":"+61","code":"AU"},{"name":"Austria","dial_code":"+43","code":"AT"},{"name":"Azerbaijan","dial_code":"+994","code":"AZ"},{"name":"Bahamas","dial_code":"+1 242","code":"BS"},{"name":"Bahrain","dial_code":"+973","code":"BH"},{"name":"Bangladesh","dial_code":"+880","code":"BD"},{"name":"Barbados","dial_code":"+1 246","code":"BB"},{"name":"Belarus","dial_code":"+375","
@doobeh
doobeh / example.html
Last active June 8, 2023 18:09
Checkbox WTForms Example (in Flask)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form method="post">
{{ form.hidden_tag() }}
{{ form.example }}
@bitboxx
bitboxx / gist:5151870
Created March 13, 2013 13:06
Javascript / jQuery: Detect page change using AJAX; auto refresh if the page is updated
// Detect page change / auto refresh
$(document).ready(function() {
var currenthtml;
var latesthtml;
$.get(window.location.href, function(data) {
currenthtml = data;
latesthtml = data;
});
@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active June 11, 2024 11:25
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@msukmanowsky
msukmanowsky / image_file_validator.py
Last active November 13, 2017 19:51
An ImageFieldRequired validator for a Flask WTForm.
from flask.ext.wtf import Form
from flask.ext.wtf.file import FileField
import imghdr
class ImageFileRequired(object):
"""
Validates that an uploaded file from a flask_wtf FileField is, in fact an
image. Better than checking the file extension, examines the header of
@zmwangx
zmwangx / rule30.py
Last active January 5, 2021 14:26
Stephen Wolfram Rule 30 cellular automaton emulation in python, with the simplest initial state of exactly one filled cell. (UPDATE: I've published a much more efficient and refined package with builtin visualization: https://github.com/zmwangx/rule30)
import sys
MAX_TIME = int(sys.argv[1])
HALF_SIZE = MAX_TIME
indices = range(-HALF_SIZE, HALF_SIZE+1)
# initial condition
cells = {i: '0' for i in indices}
cells[0] = '1'
# padding on both ends
"""
A simple example pyside app that demonstrates dragging and dropping
of files onto a GUI.
- This app allows dragging and dropping of an image file
that this then displayed in the GUI
- Alternatively an image can be loaded using the button
- This app includes a workaround for using pyside for dragging and dropping
@pkazmierczak
pkazmierczak / async-python.py
Last active November 23, 2022 09:49
asyncio example (python3 & python2)
import asyncio
@asyncio.coroutine
def factorial(name, number):
f = 1
for i in range(2, number + 1):
print("Task %s: Compute factorial(%d)..." % (name, i))
yield from asyncio.sleep(1)
f *= i