Skip to content

Instantly share code, notes, and snippets.

@sftekin
sftekin / gist:f923b0ef234b97675467f24245cc9501
Last active June 27, 2020 16:49
docker running like nohup

You need create your container first.

$ docker exec -t <container_id> python weather_pipeline.py >> /path/to/log_file/weather.log 2>&1

Ctrl + Z, to stop the job, and, bg to continue the job finally, disown %1 to disown the job. You can close terminal now and go home :)

@sftekin
sftekin / text_emoji.py
Created January 17, 2020 12:11
textual emoji count in a sentence
self.pattern_happy_emoji = re.compile(r'([:;=] ?-?(\)|D+|d+|P))')
self.pattern_unhappy_emoji = re.compile(r'(: ?-?(\(|/|([Ss]))+)')
def _extract_feature(self, sentence):
emoji_flag = np.array([0, 0])
# search for happy emoji
emoji_flag[0] = len(self.pattern_happy_emoji.findall(sentence))
# search for unhappy emoji
@sftekin
sftekin / train_clf.py
Created January 17, 2020 08:14
Manual sklearn grid_search for different classifiers
import os
import pickle
import itertools
from sklearn.model_selection import cross_val_score
from sklearn.svm import LinearSVC
from sklearn.ensemble import RandomForestClassifier
def train_model(data, word2vec, **params):
@sftekin
sftekin / warping.py
Created December 20, 2019 12:53
Example of torch.grid_sample. Warping implementation
"""
https://discuss.pytorch.org/t/solved-torch-grid-sample/51662
I have used this code.
"""
from torchvision import transforms
from PIL import Image
from PIL import ImageFile
ImageFile.LOAD_TRUNCATED_IMAGES = True