Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Tarrasch's full-sized avatar
💭
I may be slow to respond.

Arash Rouhani Tarrasch

💭
I may be slow to respond.
View GitHub Profile
@Tarrasch
Tarrasch / unikey_and_colemak.sh
Last active December 3, 2021 16:58
Something to map shortcuts to unikey_and_colemak.sh
#!/bin/bash -xe
# Usage:
# Step 1: Test that commands work when running manually
#
# example: /home/rouhani/unikey_and_colemak.sh enable_unikey
#
# Step 2:
#
# Map Desktop environment custom shortcuts to these commnads
@Tarrasch
Tarrasch / read_stdin_lines.py
Last active March 21, 2017 01:11
Python program that read stdin and put it in array line by line
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 October 5, 2016 08:04
Fix font for Vietnamese plots in matplotlib python lib
# 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
@Tarrasch
Tarrasch / VietnameseDiacritics.java
Created August 22, 2016 09:37
Vietnamese diacritics
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;
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 July 15, 2016 13:35
My TopCoder contestapplet.conf, as I don't want to keep it around in my /home folder anymore
#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 07:35
Saving and loading objects from a Path in 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 April 7, 2016 03:22
Playing around with muting exception in Java 8
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 January 16, 2016 13:40
Resources for vietnamese input

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
~/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