Skip to content

Instantly share code, notes, and snippets.

View peterkc's full-sized avatar

Peter Chanthamynavong peterkc

View GitHub Profile
@peterkc
peterkc / post-checkout
Created December 1, 2012 22:05 — forked from zeroasterisk/post-checkout
a post checkout git-hook to automatically re-run compass compile : .git/hooks/post-checkout
#!/usr/bin/perl
use strict;
use warnings;
my ($previous_head, $current_head, $is_branch_checkout) = @ARGV;
my ($is_on_facelift, $run_compass) = 0;
if ($is_branch_checkout) {
$is_on_facelift = `git branch | grep -e "^\*.*facelift"`;
chomp $is_on_facelift;

I see this error when I try to suspend an Ubuntu 10 guest in Fusion:

The request to Suspend this virtual machine failed because the corresponding VMware Tools script did not run successfully.

If you have configured a custom suspend script in this virtual machine, make sure that it contains no errors. Attempting the operation again will ignore the script failure. You can also submit a support request to report this issue.

As the dialog states, the second time you try to suspend the VM it ignores the non-zero return code of the script and it seems to work. But it's annoying.

The problem appears to not be VMware actually, but Ubuntu (or Ubuntu's service script). I tried to figure out where exactly Ubuntu's initctl configuration/scripts is broken to no avail but found a work-around that I'm happy with.

@peterkc
peterkc / 0_reuse_code.js
Created February 24, 2014 09:58
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
@peterkc
peterkc / undefined.md
Created March 4, 2014 16:54
What is the purpose of passing-in undefined?

There are two reasons for that:

  1. Since undefined is a property of the global object, without write-protection, it can be overridden which may result in strange and unexpected behavior when trying this: ( var == undefined).

By having an function argument undefined (the name actually does not matter) which you don't pass a parameter to, you make sure you have a variable which really is undefined so you can test "undefinedness" against this variable.

Btw. the safest method to test for undefined is: typeof ( var ) === 'undefined'

EDIT: With adoption of EcmaScript 5, undefined, NaN and Infinity are now readonly in all modern browsers - of course with the exception of Internet Explorer up to Version 9 :(. So this is not necessary anymore, however:

CREATE OR REPLACE FUNCTION public.json_append(data json, insert_data json)
RETURNS json
LANGUAGE sql
AS $$
SELECT ('{'||string_agg(to_json(key)||':'||value, ',')||'}')::json
FROM (
SELECT * FROM json_each(data)
UNION ALL
SELECT * FROM json_each(insert_data)
) t;
@peterkc
peterkc / async.copy.js
Last active August 29, 2015 14:12 — forked from Floby/async.copy.js
#!/usr/bin/env node
var fs = require('fs');
var async = require('async');
async.parallel([
copyFile.bind(null, 'resources/file1.txt', 'resources/file1_copy.txt'),
copyFile.bind(null, 'resources/file2.txt', 'resources/file2_copy.txt'),
copyFile.bind(null, 'resources/file3.txt', 'resources/file3_copy.txt')
], function (err, results) {

Keybase proof

I hereby claim:

  • I am peterkc on github.
  • I am peterkc (https://keybase.io/peterkc) on keybase.
  • I have a public key whose fingerprint is 5521 24A1 2988 F388 A8D1 EFB3 40F8 0F23 FACF 3553

To claim this, I am signing this object:

This is a short article on how we integrate stash and slack in openmind

First of all i assume you have:

  • a working stash installation
  • a repository you to notify slack on pushes
  • stash user with administration priviledges
  • full access to the server (linux) where stash is installed on
  • a team configured on slack
  • slack user with administration priviledges
@peterkc
peterkc / toolbar.cson
Created August 19, 2015 21:17
Use this config with the flex-tool-bar plugin for tool-bar
[
{
type: "url"
icon: "octoface"
url: "https://github.com/peterkc"
tooltip: "Github Page"
}
{
type: "url"
icon: "link"
@peterkc
peterkc / toolbar.cson
Last active August 29, 2015 14:27
Use this config with the flex-tool-bar plugin for tool-bar
[
{
type: "url"
icon: "calendar"
url: "https://www.google.com/calendar/render?tab=wc#main_7"
tooltip: "Google Calendar"
}
{
type: "spacer"
style: {