Skip to content

Instantly share code, notes, and snippets.

View timfel's full-sized avatar
👨‍🍼
Parental leave through 2024

Tim Felgentreff timfel

👨‍🍼
Parental leave through 2024
View GitHub Profile
package qt;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.trolltech.qt.core.QByteArray;
import com.trolltech.qt.core.QFile;
import com.trolltech.qt.core.QTextCodec;
def huffman filename
h = {}
open(filename) do |f|
f.read.each do |item|
unless h[item].nil?
h[item] += 1
else
h[item] = 1
end
end
Just a simple script to grab AddressBook cards from the social network StudiVZ (which is still lacking an API to do just this)
abstract class AbstractListView<S extends IDescribable> extends ViewPart implements ISelectionListener {
public java.lang.Class<?> getGenericType() {
ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass();
java.lang.Class<?> rawType = (java.lang.Class<?>) parameterizedType.getRawType();
Type actualType = parameterizedType.getActualTypeArguments()[0];
TypeVariable<?> typeVariable = rawType.getTypeParameters()[0];
return (java.lang.Class<?>) actualType;
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/* The maxium payload (to have enough space for new ips) */
>> class Test < Ohm::Model
?> attribute :name
?> set :tests, Test
?> end
=> [:tests]
>> t = Test.create(:name => "eins")
=> #<Test:3 name="eins" tests=#<Set: []>>
>> t2 = Test.create(:name => "zwei")
=> #<Test:4 name="zwei" tests=#<Set: []>>
>> t1.save
for i in $(ls app/controllers/companies_controller.rb app/controllers/contacts_controller.rb app/controllers/history_items_controller.rb app/helpers/accounts_helper.rb app/helpers/contacts_helper.rb app/models/account.rb app/models/bank_account.rb app/models/company.rb app/models/contact.rb app/models/customer.rb app/models/employee.rb app/models/history_item.rb app/models/history_observer.rb app/modules/accounts.rb app/modules/contacts.rb app/views/accounts/* app/views/companies/* app/views/contacts/* app/views/history_items/* features/contacts.feature features/accounts.feature features/history_items.feature spec/controllers/contacts_controller_spec.rb spec/controllers/contacts_routing_spec.rb spec/factories/account.rb spec/factories/contact.rb spec/factories/company.rb spec/factories/bank_account.rb spec/factories/history_item.rb spec/helpers/accounts_helper_spec.rb spec/helpers/contacts_helper_spec.rb spec/models/allmodels_spec.rb spec/models/account_spec.rb spec/models/bank_account_spec.rb spec/models/com
#!/usr/bin/env git
CURRENT_BRANCH=$(git branch --no-color | grep "*" | awk '{print $2}')
BRANCHES=$(git branch --no-color | grep -v "*")
TMPBRANCH="tmp-$(date +%Y%m%d%H%M)"
git checkout -b "$TMPBRANCH"
for i in $BRANCHES; do
git merge -s ours "$i"
done
git shortlog -n -s
git checkout "$CURRENT_BRANCH"
(Object allMethodsInCategory: 'testing')
select: [:m |
(m asString beginsWith: 'is') and:
[(m asString endsWith: ':') not]]
thenDo: [:each |
Object compile: (each asString
copyReplaceAll: 'is' with: 'if'), ': aBlock
^ self ', each asString, ' ifTrue: aBlock'.
Object organization