Skip to content

Instantly share code, notes, and snippets.

@pmuellr
pmuellr / cpu-percent.js
Created April 12, 2016 14:59
get CPU usage percent for a process in node, using proposed `process.cpuUsage()` function
'use strict'
// see: https://github.com/nodejs/node/pull/6157
var startTime = process.hrtime()
var startUsage = process.cpuUsage()
// spin the CPU for 500 milliseconds
var now = Date.now()
while (Date.now() - now < 500)
@derjohng
derjohng / xcode_ramdisk.sh
Last active June 6, 2022 03:36 — forked from skeeet/xcode_ramdisk.sh
Create a RAM disk for using with XCode, with Umount disks method
#!/bin/sh
# Create a RAM disk with same perms as mountpoint
# Script based on http://itux.idev.pro/2012/04/iservice-speed-up-your-xcode-%D0%BD%D0%B5%D0%BA%D0%BE%D1%82%D0%BE%D1%80%D1%8B%D0%B5-%D1%81%D0%BF%D0%BE%D1%81%D0%BE%D0%B1%D1%8B/ with some additions
# Usage: sudo ./xcode_ramdisk.sh start
USERNAME=$(logname)
TMP_DIR="/private/tmp"
RUN_DIR="/var/run"
@takscape
takscape / gist:2c2d175705957ddb86b3
Created December 22, 2014 01:26
国土交通省の街区レベル位置参照情報CSVのダウンロード用URLを一括取得するCasperJSスクリプト
var casper = require('casper').create();
casper.start('http://nlftp.mlit.go.jp/cgi-bin/isj/dls/_choose_method.cgi', function() {
this.echo(this.getCurrentUrl());
this.click('input[type="submit"][value=" 都道府県単位 "]');
});
casper.then(function () {
this.echo(this.getCurrentUrl());
this.click('input[id="allac"]');
@kyanny
kyanny / gist:5694201
Last active July 16, 2020 03:38
日本語概略:: RubyKaigi 2013 – great conference, but I probably wouldn’t go next year if I was a woman

RubyKaigi 2013 – great conference, but I probably wouldn’t go next year if I was a woman の内容の概略です。認識間違ってたら訂正するので @kyanny までご連絡ください。

It is a Japanese outline text of RubyKaigi 2013 – great conference, but I probably wouldn’t go next year if I was a woman. If you find any issues, please mention to @kyanny.


  • RubyKaigi 2013 のあるプレゼン中に、発表者が「おまえらが来年台湾に来るべき理由: 女の子がかわいい」という発言をした (あくまで冗談、というニュアンスで)
  • その発言に対する聴衆の反応は、拍手喝采・オオウケ、という感じだった。けどこれってまずくない?というのが元ブログの趣旨
  • ブログの著者は、この発表者の発言そのものを問題視しているのではない (全く問題が無いと思っているわけでもないが、個人攻撃は望んでいないのであえて名指ししていない / 訳者も同感です)
  • 聴衆はざっと見た感じ 95% くらいは男性で、ブログ著者は、「そういう男性ばかりの場で、女性の容姿に関する冗談に対し、そのような反応をしているのをその場に居合わせた女性が見たら、来年もまた来たいと思うのだろうか?」と言っている
@crazy4groovy
crazy4groovy / README.md
Created March 19, 2013 13:37 — forked from kirbysayshi/README.md
allow it to be used in the browser or nodejs

This Is Absolutely Tiring

Every time I start a node module, or a new JS project, I'm confronted with this same question: how do I structure it to allow it to be used in the browser or nodejs, without requiring a build step, and without getting in the way of my development?

While developing, I typically create some type of [browser-based environment][]; Firebug and Web Inspector are still miles ahead of anything else we've got. Ideally I want to be able to add a file via a script tag, and have that be the only requirement.

As @visionmedia [points out][], this is [ridiculous][].

This gist is meant to compile all of the various ways I've seen of guarding against/for a variety of module systems. Fork it and add your own, I'll try to bring them into this one.

@defunctzombie
defunctzombie / browser.md
Last active April 10, 2024 17:45
browser field spec for package.json
@jpattishall
jpattishall / TouchTimerWorkaround.js
Last active September 1, 2022 07:58
setTimeout workaround for iPad and iOS6
/**
Workaround for iOS 6 setTimeout bug using requestAnimationFrame to simulate timers during Touch/Gesture-based events
Author: Jack Pattishall (jpattishall@gmail.com)
This code is free to use anywhere (MIT, etc.)
Note: UIWebView does not support requestAnimationFrames. If your timer is failing during a scroll event,
take a look at https://gist.github.com/ronkorving/3755461 for a potential workaround.
Usage: Pass TRUE as the final argument for setTimeout or setInterval.
@uupaa
uupaa / msgpack.2.0alpha.js
Created November 18, 2012 17:34
msgpack.2.0alpha.js
/*!{id:"msgpack.js",ver:"2.0alpha",license:"MIT",author:"uupaa.js@gmail.com"}*/
(function(global) { // @arg Global: window or global
// --- header ----------------------------------------------
global.msgpack = {
pack: msgpack_pack, // msgpack.pack(mix:Mix,
// size:Integer = 16Kb):Uint8Array
unpack: msgpack_unpack // msgpack.unpack(view:Uint8Array):Mix
};