This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Round(a float64) float64 { | |
if a < 0 { | |
return math.Ceil(a - 0.5) | |
} | |
return math.Floor(a + 0.5) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Deps: lodash (or Underscore.js) | |
!function(global, appname) { | |
'use strict'; | |
var ng = angular.module(appname); | |
ng.config([ '$controllerProvider', '$compileProvider', '$filterProvider', '$provide', function($controllerProvider, $compileProvider, $filterProvider, $provide) { | |
// Register 'ngLazy' globally to allow registering of components after bootstrap. | |
// Eg: | |
// ngLazy.controller('myController', function($scope) { | |
// ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
telnet 25 | |
helo example.com | |
-250 OK | |
mail from: | |
-250 OK - mail from | |
rcpt to: | |
-250 OK - Recipient | |
data | |
-354 Send data. End with CRLF.CRLF | |
To: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kernel /vmlinuz root=/dev/sdX ro rootfsflags=subvol=<subvolume name> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mount --bind /proc /mnt/sysimage/proc | |
mount --bind /dev /mnt/sysimage/dev | |
mount --bind /sys /mnt/sysimage/sys | |
chroot /mnt/sysimage | |
cd /boot | |
mv initrd.img initrd.old.img | |
mkinitrd initrd-<ver>.img <ver> | |
cd / | |
sync; sync; sync |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reference: http://blog.gurudelleccelsopicco.org/2009/09/online-lun-expansion-and-partition-resizing-without-reboot-under-linux/ | |
echo 1 > /sys/block/[DEVICE]/device/rescan | |
# DETECT IF NEW DISKS ARE ATTACHED TO THE HOST | |
# Reference: http://www.cyberciti.biz/tips/vmware-add-a-new-hard-disk-without-rebooting-guest.html | |
ls /sys/class/scsi_host |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package timestamp | |
import ( | |
"fmt" | |
"gopkg.in/mgo.v2/bson" | |
"strconv" | |
"time" | |
) | |
type Timestamp time.Time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"labix.org/v2/mgo" | |
"labix.org/v2/mgo/bson" | |
"time" | |
) | |
type Person struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"labix.org/v2/mgo" | |
"labix.org/v2/mgo/bson" | |
"time" | |
) | |
type Person struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
var enums []string | |
type Enum int | |
func (e Enum) String() string { | |
return enums[int(e)] |