Skip to content

Instantly share code, notes, and snippets.

View mallowigi's full-sized avatar
🌴
Salut tout le monde les gens!

Elior Boukhobza mallowigi

🌴
Salut tout le monde les gens!
View GitHub Profile
@mallowigi
mallowigi / prepare-commit-msg.bash
Created February 1, 2021 14:26
Commit Message Hook
#!/bin/sh
#
# Automatically adds branch name and branch description to every commit message.
#
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master release-version)
fi
ALT_NAME=$(git branch | grep '*' | sed 's/* //')i
BRANCH_NAME=$(git symbolic-ref --short HEAD 2>/dev/null)
@mallowigi
mallowigi / git-clearHistory
Created April 9, 2020 12:01 — forked from stephenhardy/git-clearHistory
Steps to clear out the history of a git/github repository
-- Remove the history from
rm -rf .git
-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repos ensuring you overwrite history
git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPOS>.git
@mallowigi
mallowigi / downloadimage.js
Created January 18, 2017 08:39
download image
APP.getImage = function() {
var r = new XMLHttpRequest();
r.open('GET', 'https://source.unsplash.com/category/nature/100x100', true);
r.responseType = 'arraybuffer';
r.onreadystatechange = function(){
if(this.readyState === XMLHttpRequest.DONE){
if (this.status === 200) {
@mallowigi
mallowigi / ipaddr.rb
Last active July 3, 2016 17:11
Ipaddr.rb
require 'ipaddr'
# Builtin
def ip_to_int32(ip)
x = IPAddr.new(ip).to_i
end
def ip_to_int32(ip)
ip.split( '.' ).reduce( 0 ) { |total, p| total * 256 + p.to_i }
@mallowigi
mallowigi / ngswitchwhen_decorator
Last active August 29, 2015 14:12
angular ngswitchwhen decorator for dynamic usage
.config(function ($provide) {
'use strict';
$provide.decorator('ngSwitchWhenDirective', function ($delegate) {
angular.forEach($delegate, function (ngSwitchWhen) {
// override default compile method since it has already closed over
// the directive definition's link function
ngSwitchWhen.compile = function () {
@mallowigi
mallowigi / 0_reuse_code.js
Created August 31, 2014 06:11
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

A Working configuration to setup HTML5 push-state routing in your AngularJS app with Nginx as your web server.

beforeEach(function() {
this.addMatchers({
toBeInstanceOf: function(expectedInstance) {
var actual = this.actual;
var notText = this.isNot ? " not" : "";
this.message = function() {
return "Expected " + actual.constructor.name + notText + " is instance of " + expectedInstance.name;
};
return actual instanceof expectedInstance;
}
@mallowigi
mallowigi / keymap.md
Last active August 29, 2015 14:01
IntelliJ Keymap

Hola

Keymap

Editor actions

Completions

  • Add or remove caret: Alt + Left Click
    • Useful to write at multiple places at once
  • Choose lookup Item replace: Ctrl + Enter
  • Complete and replace
@mallowigi
mallowigi / JSON.parse.coffee
Created May 13, 2014 13:10
JSON parse polyfill
JSON:
parse: (string) ->
if string[0] != "{" && string[0] != "["
return null
else if window.JSON?
window.JSON.parse(string)
else
eval(string)