Skip to content

Instantly share code, notes, and snippets.

View matti's full-sized avatar
🎯
Focusing

Matti Paksula matti

🎯
Focusing
View GitHub Profile
@matti
matti / pg_dump_eats_args
Created August 2, 2016 13:34
pg_dump that eats -i for rails 3.2
#!/usr/bin/env bash
# use with ln -s pg_dump /usr/local/bin/pg_dump (or something that is before actual pg_dump in path)
actual_pg_dump=$(/usr/bin/pg_dump)
better=""
while true; do
case "$1" in
-i)
;;
@matti
matti / array-reduce-include.rb
Last active August 5, 2016 08:05
if array of string include substring with reduce
irb(main):040:0> ["abba", "bebbe", "cebbe"].reduce(false) {|a,c| (a || c.include?("xx")) }
=> false
irb(main):041:0> ["abba", "bebbe", "cebbe"].reduce(false) {|a,c| (a || c.include?("bbe")) }
=> true

Keybase proof

I hereby claim:

  • I am matti on github.
  • I am mattipaksula (https://keybase.io/mattipaksula) on keybase.
  • I have a public key whose fingerprint is 6996 7112 D611 8AD3 6CB5 23A9 B8BE B1F9 DCDD 42A8

To claim this, I am signing this object:

events {
}
http {
autoindex on;
server {
listen 80;
root /data;
}
@matti
matti / pty_spawn_stderr_stdout.rb
Created June 23, 2017 08:14
Separates Ruby PTY spawn stderr from stdout
require "pty"
stderr_reader, stderr_writer = IO.pipe
args = ["-c", "read a; echo was: $a; echo err:$a >&2"]
stdout,stdin,pid = PTY.spawn("/bin/bash", *args, err: stderr_writer.fileno)
stderr_writer.close
stdin.puts "hello"
bean program_firmware -n neljaes
2017-06-24T11:14:02.971Z INFO Setting scan timeout: 15 seconds
2017-06-24T11:14:03.218Z INFO Starting to scan...
Found device with name/address: neljaes/e2398a18d12648f499c4f61c49eda786
2017-06-24T11:14:09.134Z INFO No longer scanning...
2017-06-24T11:14:09.135Z INFO Connecting to device: neljaes
2017-06-24T11:14:09.145Z INFO Checking if device is in progress...
2017-06-24T11:14:09.145Z INFO No device is in progress!
@matti
matti / bluetooth_scan.m
Created June 25, 2017 19:16
ios objective-c scan all devices
//
// AppDelegate.m
// watlol
//
// Created by mpa on 25/06/2017.
// Copyright © 2017 mpa. All rights reserved.
//
#import "AppDelegate.h"
@import CoreBluetooth;
@matti
matti / google_mx_records_aws_route53.txt
Created July 28, 2017 07:16
google mx records aws route53
1 ASPMX.L.GOOGLE.COM.
5 ALT1.ASPMX.L.GOOGLE.COM.
5 ALT2.ASPMX.L.GOOGLE.COM.
10 ASPMX2.GOOGLEMAIL.COM.
10 ASPMX3.GOOGLEMAIL.COM.
@matti
matti / add.sh
Created July 29, 2017 11:12
alpine docker add package from edge testing
apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing \
x11vnc
ENTRYPOINT ["/bin/sh", "-c", "echo sleeping forever; while true; do sleep 99999; done"]
ENTRYPOINT ["/app/entrypoint.sh"]
trap 'exit 0' TERM
sleep inf &
wait $!