Skip to content

Instantly share code, notes, and snippets.

View jsveron23's full-sized avatar
🤫
secret

Tony Jin jsveron23

🤫
secret
View GitHub Profile
@fnichol
fnichol / README.md
Created March 12, 2011 20:52
Download a cacert.pem for RailsInstaller

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

@outsideris
outsideris / server.js
Last active January 9, 2017 02:21 — forked from nanha/node.js express logger
node.js express middleware 중에서 logger를 사용하여 실제 파일로 logging 하는 방법
/**
* express 처음에 init 하시면 app.js 를 비롯하여 여러 디렉토리가 생기는데
* logs 디렉토리에 아무것도 안남는다고 의문을 가지신 분에게 도움이 될거 같습니다.
* connect의 middleware logger 는 기본이 stdout 으로 출력하고 있었네요.
* http://senchalabs.github.com/connect/middleware-logger.html
* manual을 살펴보니 stream options 이 있었군요.
* 한번 생각나서 fs core module의 createWriteStream 을 사용하여 해봤더니 잘되네요.
* 다른 방법도 있으신분은 알려주세요
*/
var fs = require('fs'),
@soemarko
soemarko / theme.html
Created November 26, 2011 16:18
embed github gist to tumblr
<!-- Add the following lines to theme's html code right before </head> -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script>
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script>
<!--
Usage: just add <div class="gist">[gist URL]</div>
Example: <div class="gist">https://gist.github.com/1395926</div>
-->
@maxbrunsfeld
maxbrunsfeld / backbone_super.js
Created December 30, 2011 23:58
A 'super' method for backbone.js (plain javascript)
// This method gives you an easier way of calling super
// when you're using Backbone in plain javascript.
// It lets you avoid writing the constructor's name multiple
// times. You still have to specify the name of the method.
//
// So instead of having to write:
//
// User = Backbone.Model.extend({
// save: function(attrs) {
// this.beforeSave(attrs);
@ageldama
ageldama / server.js
Created January 1, 2012 06:26
node v0.6 cluster + express.js
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
@remino
remino / msconvert.js
Created January 5, 2012 05:37
JavaScript: Convert milliseconds to object with days, hours, minutes, and seconds
function convertMS(ms) {
var d, h, m, s;
s = Math.floor(ms / 1000);
m = Math.floor(s / 60);
s = s % 60;
h = Math.floor(m / 60);
m = m % 60;
d = Math.floor(h / 24);
h = h % 24;
return { d: d, h: h, m: m, s: s };
@remino
remino / datediff.js
Created January 5, 2012 06:07
JavaScript: DateDiff & DateMeasure: Calculate days, hours, minutes, seconds between two Dates
(function() {
function DateDiff(date1, date2) {
this.days = null;
this.hours = null;
this.minutes = null;
this.seconds = null;
this.date1 = date1;
this.date2 = date2;
@shazron
shazron / gist:1725083
Created February 2, 2012 18:49
PhoneGap/Cordova: Open a url in the same UIWebView programmatically
function openInWebView(url)
{
var anchor = document.createElement('a');
anchor.setAttribute('href', url);
//anchor.setAttribute('target', '_self');
var dispatch = document.createEvent('HTMLEvents')
dispatch.initEvent('click', true, true);
anchor.dispatchEvent(dispatch);
@bmitchelmore
bmitchelmore / inplace-radix.js
Created February 28, 2012 04:52
In Place Radix Sort in Javascript
var nums = [35, 25, 53, 3, 102, 203, 230, 1005];
// Figure out the number of binary digits we're dealing with
var k = Math.max.apply(null, nums.map(function(i) {
return Math.ceil(Math.log(i)/Math.log(2));
}));
for (var d = 0; d < k; ++d) {
for (var i = 0, p = 0, b = 1 << d, n = nums.length; i < n; ++i) {
var o = nums[i];
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"