Skip to content

Instantly share code, notes, and snippets.

View Abdelkrim's full-sized avatar

Abdelkrim from Brussels Abdelkrim

View GitHub Profile
@Abdelkrim
Abdelkrim / gist:6155469
Created August 5, 2013 12:11
how to call it inside the code: "debug('showAccessibleTabSelector')" src: http://www.youtube.com/watch?v=bntNYzCrzvE (minute 38:00)
//private methods
function debug(msg,info){
if(debugMode && window.console && window.console.log){
if (info){
window.console.log(info+': ',msg);
}
else{
window.console.log(msg);
}
}
@Abdelkrim
Abdelkrim / customerPaysPlanWithStripe.js
Last active January 3, 2016 03:29
0. create a customer 1. retrieve selected plan 2. charge a customer ISSUE: 1. Stripe charges twice the user with ±3 seconds delay between the charges 2. The second charge' token isn't not displayed on the web server logs
app.post('/stripeGotoStep02', function (req, res) {
var transaction = req.body;
var newCustomer = {
email: transaction.stripeCustomer.email,
plan: transaction.selectedStripePlan.id,
card: transaction.stripeToken,
description: transaction.stripeCustomer.email,
var url = require('url');
var nodedump = require('nodedump').init({ expand: true }).dump;
var stripeKPIs = require('../lib/stripeKPIs.js');
var async = require('async');
module.exports = function (app) {
app.get('/stripe/dashboard', function (req, res) {
Verifying that +abdelkrim is my Bitcoin username. You can send me #bitcoin here: https://onename.io/abdelkrim
@Abdelkrim
Abdelkrim / lat1.json
Last active May 16, 2017 12:54
Combine 2 JSON files into 1 file using Python (i.e. longitude and latitude)
{
"tags": [{
"name": "LATITUDE_deg",
"results": [{
"groups": [{
"name": "type",
"type": "number"
}],
"values": [
[1123306773000, 46.9976859318, 3],
@Abdelkrim
Abdelkrim / prepare-commit-msg
Created February 11, 2019 22:27 — forked from aemonge/prepare-commit-msg
Angular Commit Message Conventions git hook, so you got your commit prepared to with the messages they expect ;)
firstLine=`head -2 $1 | tail -1`
if [[ $firstLine == \#* ]]; then # Testing that the file starts with a comment, not yet a real commit ;)
echo '<type>(<component>): <subject>' > .prepare-commit-msg-temp
echo '' >> .prepare-commit-msg-temp
echo '<body>' >> .prepare-commit-msg-temp
echo '' >> .prepare-commit-msg-temp
echo '# types: feat, fix, docs, style, refactor, test, chore(maintain)' >> .prepare-commit-msg-temp
{ cat .prepare-commit-msg-temp; cat $1; } > .prepare-commit-msg-temp2
cat .prepare-commit-msg-temp2 > $1
build
chore (maintain i.e. updating grunt tasks etc; no production code change)
ci (continuous integration)
docs: add Blaze to list of projects
feat: Adding French translation
fix (bug fix)
perf (performance improvements)
refactor
revert
style: Welcome page tweaks for long texts. Removing ettier unnecessary changes
@Abdelkrim
Abdelkrim / format_values.py
Last active January 6, 2020 00:08
format values per thousands using python 3 : K-thousands, M-millions, B-billions.
def sizeof_number(number, currency=None):
"""
format values per thousands : K-thousands, M-millions, B-billions.
parameters:
-----------
number is the number you want to format
currency is the prefix that is displayed if provided (€, $, £...)
"""
@Abdelkrim
Abdelkrim / swap.py
Created January 8, 2020 22:44
Python : Swap values between two variables
# Swap values between two variables
a = 5
b = 10
a, b = b, a
print(a) # 10
print(b) # 5
@Abdelkrim
Abdelkrim / is_even.py
Created January 8, 2020 22:45
Python : Check if the given number is even
def is_even(num):
return num % 2 == 0
is_even(10) # True