Skip to content

Instantly share code, notes, and snippets.

View valo's full-sized avatar
👷‍♂️
buidling

Valentin Mihov valo

👷‍♂️
buidling
View GitHub Profile
@valo
valo / README.md
Last active May 30, 2018 06:59 — forked from skanev/README.md

Hacky syntax highlighting in git diff

Normally git diff would color additions green and deletions red. This is cool, but it would be even cooler if it adds syntax highlighting to those lines. This is a git pager that does so.

It parses the diff output and picks up the SHAs of files with additions and deletions. It uses [CodeRay][coderay] to highlight each file and then it extracts the lines that are shown in the diff. It then uses [term/ansicolor][color] to make a gradient from the CodeRay color and the diff color (red for deletion, green for addition) and uses it to replace the original.

I tried using rugged instead of shelling out to git show – it was faster overall, but it did incur a noticeable start up time.

Check out the image below for a demo.

$ ab -c 10 -n 100 http://178.62.172.238/rankings_practice
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 178.62.172.238 (be patient).....done
Server Software: nginx/1.4.6
@valo
valo / gist:8371134
Created January 11, 2014 13:50
public key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDIGoQM+/A5WC2j2cLvmY5cIP5bIhSFqU8AmfFmy0XtmLRzWupbk7z5BtUvYzY5X4nrB8leNnb6cFM2SgwHgQrV25Sd0YLrb4KcXxJcr45CanHWqXCBJlUwUAcWPYMjC743DXquKFypdctQOJJQfmqZmWuieaVIXNxPUB0a8LUfTE+K4M1/CHpQABm0wa4FQZ5VQrRwWyGbwK+dDB3djiYaoZetRNpRmjy70uRNP6imf5dmzUp0vDy94dWjSd+Y1ZcecZofCoUCoKnVZOZ7sGPOscy8cM7e7wZji7CltoTqeYzVEu8O7/Iej8XEfleaffFD+FAz/s/dBNHqf6lGjBc9 valentin@Valentins-MacBook-Air.local
@valo
valo / mapper.py
Last active October 14, 2021 22:01
#!/usr/bin/env python
import sys
# input comes from STDIN (standard input)
for line in sys.stdin:
# remove leading and trailing whitespace
line = line.strip()
# split the line into words
words = line.split()
require 'open-uri'
require 'thread'
# This is the index file with the filings
index_url = "http://www.sec.gov/Archives/edgar/daily-index/master.20110701.idx"
queue = Queue.new
system "mkdir -p 20110701"
Dir.chdir "20110701"
class MethodMissing
def method_missing(name, *args)
msg = name.to_s[/print_(.*)/, 1]
print msg
end
end
class LazyMethodDefine
def method_missing(name, *args)
@asp1 = Factory(:asp, :name => "ASP1", :school_name => "School 1", :school_district => "District 1", :region_id => regions(:us_co).id)
@asp2 = Factory(:asp, :name => "ASP2", :school_name => "School 2", :school_district => "District 2", :region_id => regions(:us_co).id)
@asp3 = Factory(:asp, :name => "ASP3", :school_name => "School 3", :school_district => "District 3", :region_id => regions(:us_co).id)
@asp4 = Factory(:asp, :name => "ASP4", :school_name => "School 4", :school_district => "District 3", :region_id => regions(:us_co).id)
@valo
valo / ideas.txt
Created May 12, 2011 12:41
Blog post topics
Namespaces in Ruby: what is the difference between
class A::B
end
and
module A
class B
end
import java.util.ArrayList;
import java.util.List;
public class School {
private List<SchoolClass> m_classes = new ArrayList<SchoolClass>();
private List<SchoolRoom> m_rooms = new ArrayList<SchoolRoom>();
public School() {
}
module AttributeBuilder
def initialize(attrs = {})
attrs ||= {}
attrs.each do |key, value|
self.send("#{key}=", value)
end
end
end
module MemberBuilder