Skip to content

Instantly share code, notes, and snippets.

View AlexDemian's full-sized avatar
😏

Oleksiy Demianenko AlexDemian

😏
View GitHub Profile
@AlexDemian
AlexDemian / Git comms
Last active November 30, 2018 11:40
Git comms
# Forced pull from origin (with local overwrites)
git fetch --all
git reset --hard origin/master
# .gitingore file for ignoring directory content
*
!.gitignore
@AlexDemian
AlexDemian / bash
Last active November 7, 2018 15:24
kill -9 $(ps aux | grep text_pattern | awk '{print $2}') # group process kill with filters
lsof -i :7777 #Check socket/port information
grep -Ril 'pattern' # find all files containing specific text on Linux
@AlexDemian
AlexDemian / Postgres
Last active October 22, 2018 08:56
Some postgres funcs and tricks
postgres=# SELECT now(), current_date, current_time, current_time - '1m'::interval, now() - '1m'::interval;
now | date | timetz | ?column? | ?column?
-------------------------------+------------+--------------------+--------------------+-------------------------------
2018-10-08 13:20:55.115306+00 | 2018-10-08 | 13:20:55.115306+00 | 13:19:55.115306+00 | 2018-10-08 13:19:55.115306+00
postgres=# select extract(dow from current_date);
date_part
-----------
1
@AlexDemian
AlexDemian / ajax_post
Last active October 22, 2018 08:15
FrontEnd snippets
<script>
function send_post() {
request = $.ajax({
url: "/url/",
type: "post",
data: 'forn_name='+JSON.stringify({'key':'value'})
});
request.done(function (response, textStatus, jqXHR){
console.log("Succesful!");
@AlexDemian
AlexDemian / parent.py
Created July 9, 2018 13:06
Python subprocess: recursive restart of child process(or child process group) example (Ubuntu)
import subprocess
import os
import signal
import time
path = os.path.abspath(__file__).rpartition('/')[0]
child_comm = ['python %s/child.py' % path]
parent_comm = ['python %s/parent.py' % path]
@AlexDemian
AlexDemian / Pandas
Last active July 9, 2018 12:29
Short pandas guide
#*** Create
pandas.DataFrame([], columns=['column1','column2'])
pandas.DataFrame(data={'column1':[1,2,3], 'column2': ['1','2','3']})
pandas.DataFrame([[1,1], [2,2]], columns=['column1','column2'])
#*** Get
df.values
df.columns | df.keys()