Skip to content

Instantly share code, notes, and snippets.

View maxidr's full-sized avatar

Maxi Dello Russo maxidr

  • mxHero
  • Buenos Aires, Argentina
  • X @maxidr
View GitHub Profile
@maxidr
maxidr / gist:5864069
Last active December 18, 2015 23:49
Burn iso in a USB
pv ubuntu-14.10-desktop-amd64.img.dmg | sudo dd of=/dev/rdisk3 bs=1m
pv ~/Desktop/linuxmint.iso | sudo dd of=/dev/sdx oflag=direct bs=1048576
@maxidr
maxidr / thin
Created September 18, 2013 13:37
Log rotate for thin server. You need to locate this files in folder: /etc/logrotate.d/ You can check using: logrotate -d thin
/opt/mxhero-apps/footers-web/shared/log/*.log {
daily
missingok
rotate 52
compress
delaycompress
notifempty
create 0640 ubuntu ubuntu
sharedscripts
postrotate
@maxidr
maxidr / snippet.html
Created May 22, 2015 14:45
Code snippet to paste in external sites
<script type="text/javascript">
(function(e,t,n){var r,a,c="script";e.gigwell=e.gigwell||{},r=t.createElement(c),
a=t.getElementsByTagName(c)[0],r.async=1,r.src=n,a.parentNode.insertBefore(r,a)
})(window,document,'https://static.bookongigwell.com/booking-widget.min.js');
gigwell.agencyId = 'x81998c8j812'; // Required
gigwell.artistId = '821x988122d'; // Optional
// optional
@maxidr
maxidr / loadScript.js
Created June 5, 2015 16:47
Load JS on demand
// Inspired (stolen?) from JQuery (https://github.com/jquery/jquery/blob/1.3.2/src/ajax.js#L264)
// and http://www.nczonline.net/blog/2009/07/28/the-best-way-to-load-external-javascript/
function loadJS(url, callback){
var head = document.getElementsByTagName("head")[0];
var script = document.createElement("script");
script.src = url;
script.async = true;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function(){
@maxidr
maxidr / example.js
Last active August 29, 2015 14:22
Object.defineProperty helps to define (for example) read only
// Example take from the book Java Application Design (http://www.bevacqua.io/buildfirst)
// https://github.com/buildfirst/buildfirst/blob/master/ch05/06_prototypal-modularity/protolib.js
// Still using an IIFE to expose the library!
(function(window){
// use these to sign each instance and access its private scope
var lastId = 0;
var data = {};
function Lib () {
@maxidr
maxidr / 0_reuse_code.js
Last active August 29, 2015 14:24
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
@maxidr
maxidr / randomHash.js
Last active August 29, 2015 14:24
Random hash in hexa: In nodejs (randomHash.js) In browser (randomHashBrowser.js)
var crypto = require('crypto');
crypto.randomBytes(16).toString('hex');
// 'e834ba2133229fb78a693f5ca3ae05de'
@maxidr
maxidr / routes.js
Last active August 29, 2015 14:26
#mithril Route separation logic example From https://gitter.im/lhorie/mithril.js?at=551bd24305184cd235fb971a
// The limited unauthenticated routemap
var authRoutes = {
'/signup' : modules.signup,
'/login' : modules.login
};
// The whole shebang
var appRoutes = Object.assign( {
'/:semantic/:app/:routes' : various.modules
}, authRoutes );
void function(m) {
function closure(fn) {
var component = {
controller : function(options) {
component.view = fn(options);
}
};
return component;