Skip to content

Instantly share code, notes, and snippets.

View murillomarigo's full-sized avatar

Murillo Marigo murillomarigo

  • São Paulo - Brazil
View GitHub Profile
@murillomarigo
murillomarigo / DirectoryInfoExtensions.cs
Last active December 18, 2015 01:59
C# DirectoryInfoExtensions - Directory CopyTo method (found at http://channel9.msdn.com/forums/TechOff/257490-How-Copy-directories-in-C/)
public static class DirectoryInfoExtensions
{
/*
Usage
var source = new DirectoryInfo(@"C:\users\chris\desktop");
source.CopyTo(@"C:\users\chris\desktop_backup", true);
*/
public static void CopyTo(this DirectoryInfo source,string destDirectory, bool recursive)
{
if (source == null)
@murillomarigo
murillomarigo / date_utils.js
Created June 4, 2013 17:47
Javascript Date Utils -secondsToHms -hmsToSeconds
function secondsToHms(d) {
d = Number(d);
var h = Math.floor(d / 3600);
var m = Math.floor(d % 3600 / 60);
var s = Math.floor(d % 3600 % 60);
return ((h > 0 ? h + ":" : "") + (m > 0 ? (h > 0 && m < 10 ? "0" : "") + m + ":" : "0:") + (s < 10 ? "0" : "") + s);
}
function hmsToSeconds(str) {
var p = str.split(':'),
s = 0, m = 1;
.display-box() {
display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6 */
display: -moz-box; /* OLD - Firefox 19- (buggy but mostly works) */
display: -ms-flexbox; /* TWEENER - IE 10 */
display: -webkit-flex; /* NEW - Chrome */
display: flex;
display: box;
}
.box-direction(@value) {
@murillomarigo
murillomarigo / 0_reuse_code.js
Created May 7, 2014 20:45
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
var x = [ {"id":1,"start":"\/Date(1238540400000)\/"}, {"id":2,"start":"\/Date(1238626800000)\/"} ];
var myDate = new Date(x[0].start.match(/\d+/)[0] * 1);
Date.prototype.format = function(format) //author: meizz
{
var o = {
"M+" : this.getMonth()+1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"q+" : Math.floor((this.getMonth()+3)/3), //quarter
"S" : this.getMilliseconds() //millisecond
@murillomarigo
murillomarigo / monthFirstDay.sql
Created August 8, 2014 14:13
First day of the current month
SELECT DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0)
@murillomarigo
murillomarigo / monthLastDay.sql
Created August 8, 2014 14:13
Last day of the current month
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE())+1,0))
git commit --amend -m "New commit message"
@murillomarigo
murillomarigo / ExecuteAsRootBase.cs
Last active May 1, 2018 19:50
Check and request root using xamarin android
using System;
using Java.Lang;
using System.Collections.Generic;
/*
http://forums.xamarin.com/discussion/21437/app-with-root-access
Alejandro Ruiz
*/
namespace NMDSAndroid.Infraestrutura