Skip to content

Instantly share code, notes, and snippets.

View kaisbensalah's full-sized avatar

Kais Ben Salah kaisbensalah

View GitHub Profile
@kaisbensalah
kaisbensalah / mysql2pg.sh
Last active October 7, 2019 16:27
Script for converting MySQL DDL to PostgreSQL-compatible one
sed -i 's/`/"/g' DDL.sql
sed -i 's/SET FOREIGN_KEY_CHECKS = 0;//g' DDL.sql
sed -i 's/SET FOREIGN_KEY_CHECKS = 1;//g' DDL.sql
sed -i 's/TINYINT/SMALLINT/g' DDL.sql
@kaisbensalah
kaisbensalah / seeds.rb
Created October 5, 2019 15:38 — forked from seyhunak/seeds.rb
Rails - Import SQL file as seed
unless Rails.env.production?
connection = ActiveRecord::Base.connection
connection.tables.each do |table|
connection.execute("TRUNCATE #{table}") unless table == "schema_migrations"
end
sql = File.read('modeling/DDL_Export/DDL.sql')
statements = sql.split(/;$/)
statements.pop
Outer window is 0xa200001, inner window is 0xa200002
PropertyNotify event, serial 8, synthetic NO, window 0xa200001,
atom 0x27 (WM_NAME), time 120633188, state PropertyNewValue
PropertyNotify event, serial 9, synthetic NO, window 0xa200001,
atom 0x22 (WM_COMMAND), time 120633188, state PropertyNewValue
PropertyNotify event, serial 10, synthetic NO, window 0xa200001,
atom 0x28 (WM_NORMAL_HINTS), time 120633188, state PropertyNewValue
@kaisbensalah
kaisbensalah / gist:362bf941d9ce04168c93c2f39b24533c
Created August 9, 2019 13:48
Results of VM statistics, when Linux gets freezed because of throttling
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
2 29 3659608 1103164 31984 982756 472 0 2002 201 1973 4193 32 18 2 48 0
1 30 3657560 1090500 34872 988828 463 0 2148 159 1834 3881 32 19 5 44 0
3 22 3656024 1075632 36076 1003512 470 0 2851 62 1871 3582 34 18 0 47 0
2 28 3653976 1082376 39124 992252 466 0 2880 78 2085 4105 39 22 1 38 0
2 30 3651416 1068444 40916 1007800 509 0 2968 100 1844 4005 32 17 2 48 0
1 29 3649368 1067652 43072 1020320 495 0 2582 79 1977 4161 39 23 0 37 0
1 30 3648088 1046932 45984 1037812 266 0 3144 45 1972 4291 32 18 4 47 0
5 30 3646808 1032580 48260 1050544 239 0 3070 174 1876 4833 30 17 2 51 0
@kaisbensalah
kaisbensalah / serial_port_buffer_read_at_once.py
Last active July 4, 2018 20:03
reading from serial port without in_waiting property checking
while True:
buffer = serial_port.read()
print('buffer=', buffer)
ascii = buffer.decode('ascii')
if len(ascii) > 0:
print('ascii=', ascii)
@kaisbensalah
kaisbensalah / gist:dca44bd04d8c94eef1de4d358c2213ea
Created January 24, 2018 18:21
`orderIsReverse([])` added
orderIsReverse(L):-
[X|Q]=L,
[XP|_]=Q,
(X<XP -> false; orderIsReverse(Q)),
orderIsReverse([]).
@kaisbensalah
kaisbensalah / gist:29e55f380838c64d48fd500e964429a2
Created January 24, 2018 16:28
Arithmetic: `maxP(_7182,_7204)' is not a function
maxP(L,X):-
[H|Q]=L,
(X<H -> X=H),
maxP(Q,X),
true.
max([H|Q], Max) :-
max(Q, H, Max).
max([], Max, Max).