Skip to content

Instantly share code, notes, and snippets.

#--------------------------------------------------------------------
######### Printer type setting ##################################
#mainboard firmware setting(marlin:1; repetier:2; smoothie:3)
>cfg_firmware_type:1
#machine setting (Normal:1; Delta:2)
>cfg_machine_type:1
#baud rate (9600:1; 57600:2; 115200:3; 250000:4)
.then(function(response) {return response.json();}).then(function(myJson) {console.log(myJson);});
function selectElementContents(el) {
var body = document.body, range, sel;
if (document.createRange && window.getSelection) {
range = document.createRange();
sel = window.getSelection();
sel.removeAllRanges();
try {
range.selectNodeContents(el);
@tsohr
tsohr / gist:ec7903809e0a5c73d03d4c8308bc522d
Last active October 6, 2018 15:49
Bucardo session replication role hack
#must read
# https://www.compose.com/articles/using-bucardo-5-3-to-migrate-a-live-postgresql-database/
# https://www.sqlgossip.com/configure-bucardo-replication-centos/
# https://www.srijn.net/2015/09/postgresql-replication-using-bucardo/
5324 ## Can we do this the easy way? Thanks to Jan for srr!
5325 my $dbname = $db->{name};
5326 if ($dbh->{pg_server_version} >= 80300) {
5327 $self->glog("Setting session_replication_role to replica for database $dbname", LOG_VERBOSE);
@tsohr
tsohr / vimrc
Last active July 2, 2018 04:28
my vim settings
set nocompatible " Use Vim defaults (much better!)
set bs=indent,eol,start " allow backspacing over everything in insert mode
set viminfo='20,\"50 " read/write a .viminfo file, don't store more
" than 50 lines of registers
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set hlsearch
filetype plugin on
@tsohr
tsohr / keymap.cson
Created June 7, 2018 02:33
my atom keybinding settings
'body':
'': 'core:save-as'
'atom-workspace atom-text-editor':
'ctrl-backspace': 'editor:delete-to-previous-word-boundary'
'ctrl-delete': 'editor:delete-to-next-word-boundary'
'atom-text-editor':
'ctrl-i': 'editor:auto-indent'
@tsohr
tsohr / screen_capture_periodically.sh
Last active April 16, 2018 04:45
screen capture periodically
wget "https://raw.githubusercontent.com/npocmaka/batch.scripts/master/hybrids/.net/c/screenCapture.bat" -O screenCapture.bat
chmod a+x screenCapture.bat
#capture from cron didn't work because the windows session connected to a different session from the desktop user
cat > capture.sh <<'EOF'
#!/bin/bash
DIR=`date +"%Y/%m/%d"`;
FILE=`date +"%Y%m%d-%H%M%S"`;
mkdir -p "$HOME/screenCapture/$DIR";
ICACLS * /T /Q /C /RESET
@tsohr
tsohr / nginx.conf
Created October 30, 2017 01:34
nginx conf
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
aws ec2 describe-instances --query 'Reservations[*].Instances[*].[PublicDnsName, Tags[?Key==`Name`].Value]' --region=us-east-1 --output text
private static final SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH);
private static final FastDateFormat fmt = FastDateFormat.getInstance("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");