Skip to content

Instantly share code, notes, and snippets.

View ruanyl's full-sized avatar

Yulong Ruan ruanyl

  • Amazon Web Service
View GitHub Profile
@ruanyl
ruanyl / install_pig
Last active October 31, 2023 10:01
install and setup pig in macos
This gist assuming that you have apahce hadoop installed and running.
step to install and config pig:
>1. brew install pig
>2. export JAVA_HOME="$(/usr/libexec/java_home)"
>3. export PIG_CLASSPATH=/path/to/pig.jar, normally if you install pig via homebrew, the path should be like:/usr/local/Cellar/pig/0.13.0/pig-0.13.0-h1.jar
step 2 & 3 are mandatory for me, otherwise *pig* wont work.
@ruanyl
ruanyl / js_bind_cross_browser
Created August 27, 2014 10:51
allowing use of much of the functionality of bind() in implementations that do not natively support it.
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5
// internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' --abbrev-commit"
function set_headers($file, $timestamp) {
$gmt_mtime = gmdate('r', $timestamp);
header('ETag: "'.md5($timestamp.$file).'"');
header('Last-Modified: '.$gmt_mtime);
header('Cache-Control: public');
if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
if ($_SERVER['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime
|| str_replace('"', '', stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])) == md5($timestamp.$file)) {
header('HTTP/1.1 304 Not Modified');
exit();
@ruanyl
ruanyl / test.js
Created August 16, 2014 05:10 — forked from Spoygg/test.js
describe('Test example.com', function(){
before(function(done) {
client.init().url('http://example.com', done);
});
describe('Check homepage', function(){
it('should see the correct title', function(done) {
client.getTitle(function(err, title){
expect(title).to.have.string('Example Domain');
done();
module.exports = {
'can log in at vimeo': function (test) {
'use strict';
test.expect(1)
.open('http://vimeo.com/log_in')
.type('#email', 'foo@bar.com')
.type('#password', 'baz')
.click('.submit .btn')
.assert.text('#page_header h1 a', 'foobar')
@ruanyl
ruanyl / gist:fc41aefedbe287e69dcf
Created August 12, 2014 07:35
css text shadow
html, body {
height: 100%;
}
body {
margin: 0;
background: #0A539C;
background: linear-gradient(top, #4293d6 0%,#001e96 100%);
overflow: hidden;
}
@ruanyl
ruanyl / vim_buffer_in_new_split
Created August 11, 2014 08:57
vim open buffer on new split
:vert sb N
which will open a left vertical split (by default, unless you have modified some options).
To open a split to the right, on the other hand:
:vert belowright sb N
@ruanyl
ruanyl / php_status_code
Created August 8, 2014 09:29
send status code in php
header('HTTP/1.1 304 Not Modified');exit();