Skip to content

Instantly share code, notes, and snippets.

Avatar

Janko Marohnić janko

View GitHub Profile
@steveklabnik
steveklabnik / rails4gems.md
Last active Dec 19, 2015
Gems that may not be rails 4 compatible
View rails4gems.md
@mislav
mislav / install.sh
Last active Dec 19, 2015
Test-drive the new vim 7.4 prerelease
View install.sh
cd /tmp
wget ftp://ftp.vim.org/pub/vim/unstable/unix/vim-7.4a.tar.bz2 -O- | tar -xj
cd vim74a
sudo mkdir -p /opt/vim
sudo chown $USER /opt/vim
PATH=/usr/bin:/usr/sbin:/bin:/sbin ./configure --prefix=/opt/vim --enable-rubyinterp | grep ruby
make && make install
View gist:6819142
Date: Thu, 3 Oct 2013 17:16:51 -0700
From: Gary Bernhardt <gary.bernhardt@gmail.com>
To: info@wdsearch.com
Subject: Mailing practices
I suspect that you guys know this, but just in case: your emailing
practices have been resulting in... less than good impressions among the
people you aim to recruit. Here are some tweets, none of which were
written by me:
@mpapis
mpapis / bad.rb
Last active Jan 1, 2016
I hate asymmetrical code
View bad.rb
apply_event :transfer_sent, :target_account_uid => target,
:amount => amount,
:new_balance => new_balance.amount,
:account_uid => uid
@n1k0
n1k0 / location.js
Created Jul 4, 2012
PhantomJS test script for window.location
View location.js
var page = require('webpage').create();
var base = phantom.args[0];
var path = phantom.args[1];
var expected = phantom.args[2];
page.onNavigationRequested = function(url, navigationType, navigationLocked, isMainFrame) {
console.log('Navigation requested: ' + navigationType + '; ' + url);
if (!page.testStarted) {
return;
}
@MarkMurphy
MarkMurphy / README.md
Last active Aug 7, 2016
Multipart Upload API
View README.md

Endpoints for uploading large files in multiple chunks. Also has the ability to resume if the upload is interrupted.

Typical usage:

  1. Send a POST request to /files with the first chunk of the file and receive an upload id in return.
  2. Repeatedly PATCH subsequent chunks using the upload id to identify the upload in progress and an offset representing the number of bytes transferred so far.
  3. After each chunk has been uploaded, the server returns a new offset representing the total amount transferred.
  4. After the last chunk commit the upload by passing its id to another endpoint such as POST /videos, POST /audio, etc.

Example:

@jordwalke
jordwalke / gist:6350319
Last active Sep 10, 2016
ReactJS: JavaScript just like you've always done it.
View gist:6350319
/**
* ReactJS: JavaScript like you've always done it.
*
* This example renders your top ten most followed friends/followers, `filter`ing
* only your favorites, and putting a star on all verified accounts.
*
* With ReactJS, any time your data changes, the UI is always brought up to date
* automatically. If friends length changes, or followCount - it always shows what
* `render` describes.
*/
@radu-gheorghe
radu-gheorghe / logstash.conf
Created Mar 17, 2016
logstash grok filter for Elasticsearch logs
View logstash.conf
filter {
if [type] == "elasticsearch" {
grok {
match => [ "message", "\[%{TIMESTAMP_ISO8601:timestamp}\]\[%{DATA:severity}%{SPACE}\]\[%{DATA:source}%{SPACE}\]%{SPACE}(?<message>(.|\r|\n)*)" ]
overwrite => [ "message" ]
}
if "_grokparsefailure" not in [tags] {
grok { # regular logs
match => [
@xaviershay
xaviershay / http_client_spec.rb
Created Dec 13, 2011
Running a rack app in a thread for integration tests.
View http_client_spec.rb
require 'integration_helper'
require 'rack'
require 'rack/handler/webrick'
describe HttpClient do
before :all do
@server = WEBrick::HTTPServer.new(
:Port => 9293,
:Logger => Rails.logger,
:AccessLog => Rails.logger
@tenderlove
tenderlove / terrible.rb
Last active May 16, 2020
I am a terrible person
View terrible.rb
require 'fiddle'
module IAmAHorriblePerson
def unset flag
value = _wrap self
flags = 8.times.map { |i| value[i] }.pack('C8').unpack('Q').first
[flags & ~flag].pack('Q').unpack('C8').each_with_index { |n,i|value[i] = n }
end
def class= k