Skip to content

Instantly share code, notes, and snippets.

💭
I may be slow to respond.

Arash Rouhani Tarrasch

💭
I may be slow to respond.
Block or report user

Report or block Tarrasch

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Tarrasch
Tarrasch / read_stdin_lines.py
Last active Mar 21, 2017
Python program that read stdin and put it in array line by line
View read_stdin_lines.py
import sys
def main():
stdin_lines = []
for line in sys.stdin:
if line.strip() != "":
stdin_lines.append(line.strip())
# ... My code here ...
@Tarrasch
Tarrasch / untested.py
Created Oct 5, 2016
Fix font for Vietnamese plots in matplotlib python lib
View untested.py
# I Used this with a IPython notebook using pandas, but I suppose that part isn't relevant
#
# Big thanks to guy who wrote this: http://www.himpactwxlab.com/home/how-to-wiki/change-matplotlib-fonts
#
# I had the problem that vietnamese characters showed as empty boxes. Although tones displayed properly.
# Here's the code to fix it:
import matplotlib
import matplotlib.font_manager as font_manager
View VietnameseDiacritics.java
public class VietnameseDiacritics {
// this is only pseudo code, not meant to compile
public static String allVietnameseCombiningDiacriticalMarks() {
String s = "ạàáãảâăư"; // đ is not counted as a diacratic apparently
s = java.text.Normalizer.normalize(s, java.text.Normalizer.Form.NFD);
s = s.replaceAll("[^\\p{InCombiningDiacriticalMarks}]", "");
return s;
View hackathon-idea-saigon-2016.txt
Okay. I finally have an idea! I'm writing it here since some people asked me about it in a PM. I think this idea could be useful because: (1) it's quite simple (2) it only uses one technology (Messenger API) and (3) is localized to Saigon (4) the completed product could be monetized (although I don’t have that ambition :)). Furthermore I would like something like this myself. For added cuteness and confusion I'm trying to write the rest of the post in Vietnamese:
Lúc nào tôi cũng muốn đi ăn uống với những bạn, tụi tôi phải chọn một chỗ. foody.vn là rất tất tại vì có review, có địa chỉ, có ảnh rõ đẹp. Nhưng mà tôi thấy là foody.vn và nhũng site bằng đó thiếu một feature. Đó là rất là khó kiếm tìm chỗ. Tại sao?
foody.vn không có map tốt, site lúc nào cũng chậm, có ads vói lại tôi thấy là foody.vn là scroll hell. Xong rồi
Với chatbot, có thể mình được implement một cuộc trò chuyện như sau:
người dùng: Tôi muốn ăn
bot: ở đâu vậy? (với lại tặng suggestion nên làm interface dễ dùng)
@Tarrasch
Tarrasch / contestapplet.conf
Created Jul 15, 2016
My TopCoder contestapplet.conf, as I don't want to keep it around in my /home folder anymore
View contestapplet.conf
#TopCoder ContestApplet Preferences File
#Sat Apr 19 19:43:11 CEST 2014
com.topcoder.client.contestApplet.common.LocalPreferences.menufont=Arial
com.topcoder.client.contestApplet.common.LocalPreferences.menufontsize=10
com.topcoder.client.contestApplet.common.LocalPreferences.commonclasspath=/home/arash/tprog/TCws/
com.topcoder.client.contestApplet.LocalPreferences.connectionType=DIRECT
com.topcoder.jmaContestApplet.frames.codingframe.location=0\:25
com.topcoder.jmaContestApplet.frames.codingframe.size=1920\:1055
com.topcoder.jmaContestApplet.frames.codingframe.dividerloc=434
com.topcoder.jmaContestApplet.frames.sourceViewer.location=0\:25
@Tarrasch
Tarrasch / SaveLoadObject.java
Last active May 17, 2016
Saving and loading objects from a Path in Java
View SaveLoadObject.java
// These methods could be pasted in a class.
// I found these two implementations to be better than what was provided in various library-provided util classes. Because these methods mute no exceptions.
// These version are also not dependent if you use files from disk or not.
private static void writeObjectToDisk(Object o, Path p) throws IOException {
try (OutputStream os = Files.newOutputStream(p);
ObjectOutputStream oos = new ObjectOutputStream(os)) {
oos.writeObject(o);
@Tarrasch
Tarrasch / Helpers.java
Created Apr 7, 2016
Playing around with muting exception in Java 8
View Helpers.java
public class Helpers {
public static <T> T getWithRTE(ExceptionSupplier<T> exceptionThrower) {
try {
return exceptionThrower.get();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Tarrasch
Tarrasch / instructions.md
Last active Jan 16, 2016
Resources for vietnamese input
View instructions.md

Goal

I want to use colemak+telex on Ubuntu 14.04. Preferably switching betweeen them with a keyboard shortcut.

Details

canhaz ibus-unikey
sudo cp /usr/share/ibus/component/unikey.xml{,-orig}
curl https://gist.githubusercontent.com/lewtds/14ca841f7331126ad66b/raw/86b525d474e803995dd85833fd8ae41496a5633d/unikey.xml | sudo tee /usr/share/ibus/component/unikey.xml
View gist:830e0a22ee4af120fc86
~/spotify/repos/gcp-migrate various-improvements
❯ git remote -v
origin git@ghe.spotify.net:arash/gcp-migrate.git (fetch)
origin git@ghe.spotify.net:arash/gcp-migrate.git (push)
upstream https://ghe.spotify.net/datainfra/gcp-migrate.git (fetch)
upstream https://ghe.spotify.net/datainfra/gcp-migrate.git (push)
~/spotify/repos/gcp-migrate various-improvements
❯ git fetch --all
Fetching origin
@Tarrasch
Tarrasch / stream_count.py
Created Aug 29, 2014
Currently, our skeleton doesn't instantiate everything
View stream_count.py
import datetime
import luigi
from spotify.luigi.crunch import ScrubJobTask, load_avsc
from spotify.luigi import HdfsTarget
from spotify.luigi.external_shrek_anonym import CreateEndSongCleaned
class SampleEndSongSubset(luigi.ExternalTask):
def output(self):
return HdfsTarget("/user/spotify-analytics-data/examples/data_pipeline_crunch/stream_count_anonym")
You can’t perform that action at this time.