Skip to content

Instantly share code, notes, and snippets.

@morgotth
morgotth / last-jtop
Created April 26, 2018 16:13
last jtop ranking
move dogfight
ikusen koken no kodoku - the back horn
ready steady go - l'arc en ciel
43. dream figher - perfume
42. spice - perfume
41. answer is near - ONE OK ROCK
40. lottara lottara - Buono
39. agian - YUI
38. dandelion - kokia
37. rain - YUI
@morgotth
morgotth / edit_tags.sh
Last active September 15, 2015 09:38
Edit tag messages and preserving original date
for tag in $(git tag -l);do
# Checkout this tag
git co $tag > /dev/null
# Retrieve tag date
GIT_COMMITTER_DATE=$(git sh $tag | head -n 3 | tail -n 1 | cut -c 9-);
echo "$tag: $GIT_COMMITTER_DATE"
# Edit tag message but preserving date (TODO: author?)
GIT_COMMITTER_DATE="$GIT_COMMITTER_DATE" git tag $tag -a --force
done
@morgotth
morgotth / FooAdapter.java
Last active October 26, 2019 14:12
Recycled Pager Adapter inspired by RecyclerView
package com.example;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.Foo;
import com.example.RecycledPagerAdapter;
public class FooAdapter extends RecycledPagerAdapter<FooViewHolder> {
@morgotth
morgotth / WrapperTest.java
Last active August 29, 2015 14:17
Avoid wrapper instanciation hell with 2 functions and 1 interface !
public class WrapperTest {
public static void main(String[] args) throws ReflectiveOperationException {
Developer myProfile = wrap(MainDeveloper.class, PythonDeveloper.class, UnixDeveloper.class);
System.out.println(myProfile.develop());
}
public static <T> T wrap(Class<T> t, Class... classes) throws ReflectiveOperationException, ClassCastException {
return wrap(t.newInstance(), classes);
}
➜ ~ python turing.py
1) idx=0 on [1, 1] with state=e1
2) idx=1 on [0, 1] with state=e2
3) idx=2 on [0, 1] with state=e2
4) idx=3 on [0, 1, 0] with state=e3
5) idx=2 on [0, 1, 0, 1] with state=e4
6) idx=1 on [0, 1, 0, 1] with state=e5
7) idx=0 on [0, 1, 0, 1] with state=e5
8) idx=1 on [1, 1, 0, 1] with state=e1
9) idx=2 on [1, 0, 0, 1] with state=e2
@morgotth
morgotth / nhk_rss.py
Created February 28, 2015 11:25
Generate NHK Japanese Lessons RSS feed. See http://www3.nhk.or.jp/lesson/english/index.html
content = u""
ep = 44
while ep > 0:
content += u"""
<item>
<enclosure url="http://www.nhk.or.jp/lesson/audio/english/Lesson{i}.mp3" length="4802040" type="audio/mpeg"></enclosure>
<title>English : lesson{i}</title>
<itunes:author>NHK WORLD RADIO JAPAN</itunes:author>
<itunes:duration>10:00</itunes:duration>
<itunes:category text="Education">
@morgotth
morgotth / events.libirumveto.txt
Created September 17, 2013 10:14
EU4 libirumveto event
##################Liberum Veto################
# These happen if you do the decision for it #
# Further concession demanded
country_event = {
id = 6501
title = "EVTNAME6501"
desc = "EVTDESC6501"
picture = LIBERUM_VETO_eventPicture