Skip to content

Instantly share code, notes, and snippets.

View radiospiel's full-sized avatar
💭
nothing to see here

eno radiospiel

💭
nothing to see here
View GitHub Profile
@radiospiel
radiospiel / chiliproject_to_redmine.rb
Last active December 11, 2015 13:21 — forked from pallan/chiliproject_to_redmine.rb
Run this script from the root of your Redmine installation to convert from a Chiliproject installation. This script tries to preserve the wiki history.
# encoding: UTF-8
# Chiliproject to Redmine converter
# =================================
#
# This script takes an existing Chiliproject database and
# converts it to be compatible with Redmine (>= v2.3). The
# database is converted in such a way that it can be run multiple
# times against a production Chiliproject install without
# interfering with it's operation. This is done by duplicating
func copy(dest io.Writer, src io.Reader) int64 {
// If dest has a ReadFrom method, we use that. This gives us zero copy
// when copying between sockets, for example.
if reader_from_dest, ok := dest.(io.ReaderFrom); ok {
written, _ := reader_from_dest.ReadFrom(src)
return written
}
buf := make([]byte, 1024 * 16)
@radiospiel
radiospiel / gist:baa9f7f809ecab4eef63
Created September 7, 2014 10:03
go bidirectional copying
func BidirectionalCopy(conn net.Conn, channel net.Conn) {
start := time.Now()
var done = make(chan int, 1)
go copy("to ssh channel", conn, channel, done)
go copy("from ssh channel", channel, conn, done)
written := <-done
conn.Close()
channel.Close()
class Movie < ActiveRecord::Base
end
module Crawler
extend self
def run
html = Net::HTTP.get "..."
doc = Nokogiri.HTML(html)
doc.css(".movies").each do |movie|
class Nokogiri::HTML::Document
def meta_encoding
content_type = css("meta[http-equiv=content-type]").each do |meta|
break meta.attribute("content").value
end
return unless content_type
content_type.split("; ").each do |part|
next unless part =~ /^charset=(.*)/
eno@paddy:~/openwrt-sdk/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2$ svn export svn://svn.openwrt.org/openwrt/packages/utils/nano package/nano
A package/nano
A package/nano/Makefile
Exported revision 35148.
eno@paddy:~/openwrt-sdk/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2$ grep DEPENDS package/nano/Makefile
DEPENDS:=+libncurses
eno@paddy:~/openwrt-sdk/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2$ svn export svn://svn.openwrt.org/openwrt/trunk/package/ncurses package/ncurses
svn: E170000: URL 'svn://svn.openwrt.org/openwrt/trunk/package/ncurses' doesn't exist
eno@paddy:~/openwrt-sdk/OpenWrt-SDK-x86-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2$ svn export svn://svn.openwrt.org/openwrt/trunk/package/libs/ncurses package/ncurses
A package/ncurses
require "curb"
class Neography::Rest
class Curl::Easy
def parsed_response
@parsed_response ||= MultiJsonParser.new(body_str, :json).send(:json)
end
alias :body :body_str
alias :code :response_code
#include <sys/time.h> // for gettimeofday()
class StopWatch {
timeval started;
std::string msg;
public:
StopWatch(const std::string& m): msg(m)
{ gettimeofday(&started, NULL); }
#include <iostream>
#include <algorithm>
#include <vector>
#include "stop_watch.inl" // see https://gist.github.com/2057981
#ifndef COUNT
#define COUNT 100000000
#endif
int compare_int(const void* p1, const void* p2)
@radiospiel
radiospiel / localpod.mdown
Created March 9, 2012 22:41
How I use Cocoapod locally
  1. Preparation

Setup a local CocoaPods directory, and register it with CocoaPods

mkdir -p ~/CocoaPods/Local
(cd ~/CocoaPods/Local; git init)
pod repo add ~/CocoaPods/Local
  1. Update local CocoaPod