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 / millisecondsToHMS.coffee
Last active August 29, 2015 14:01
millisecondsToHMS
millisecondsToHMS: (ms) ->
hms = {
h: Math.floor(ms/(60*60*1000)),
m: Math.floor((ms/60000) % 60),
s: Math.floor((ms/1000) % 60)
}
tc = []
tc.push(hms.h) if (hms.h > 0)
m = hms.m;
@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)
@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
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;
}

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

@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
@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 / .bowerrc
Created September 16, 2013 15:04 — forked from facultymatt/.bowerrc
{
"directory": "components"
}
@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 / 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) {