Skip to content

Instantly share code, notes, and snippets.

heroku pg:backups:capture
heroku pg:backups:download
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump
@letz
letz / posrgresql.txt
Created July 24, 2017 15:29
role for postgresql
create role DBNAME with createdb login;
create role DBNAME with createdb login password 'password1';
@letz
letz / NodeMCU-MQTT-Siri-Wifi-Light.ino
Created December 23, 2016 00:11 — forked from jamesabruce/NodeMCU-MQTT-Siri-Wifi-Light.ino
Wi-Fi Neopixel light controlled over MQTT, to be connected through HAP-NodeJS to Siri
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <PubSubClient.h>
#include <Adafruit_NeoPixel.h>
#define PIN 4
Adafruit_NeoPixel strip = Adafruit_NeoPixel(4, PIN, NEO_GRB + NEO_KHZ800);
@letz
letz / decode_session_cookie.rb
Created September 23, 2016 13:38 — forked from pdfrod/decode_session_cookie.rb
A simple script to decode Rails 4 session cookies
@letz
letz / websocket-rails_message_format.js
Created February 10, 2016 14:00 — forked from DanKnox/websocket-rails_message_format.js
Format of WebsocketRails Messages
/****** Current Format ******/
// Basic Message
metadata = {
id: 1234234234, // Randomly generated by the client. Used for receiving success/fail callbacks
client_id: 123456 // Sent from the server with the `websocket_rails.client_connected` event which is sent after the connection is opened. Store this and send it with each message.
data: {name: 'shoes'} // Arbitrary data. Can be Object or String. This is available through #message or #data in the controller.
}
event = ["products.new", metadata]
@letz
letz / AndroidDevice.java
Created July 3, 2015 13:34
Check if android device is tablet or smartphone
DisplayMetrics metrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
float yInches= metrics.heightPixels/metrics.ydpi;
float xInches= metrics.widthPixels/metrics.xdpi;
double diagonalInches = Math.sqrt(xInches*xInches + yInches*yInches);
if (diagonalInches>=6.5){
// 6.5inch device or bigger
}else{
// smaller device
================================================================================
Error executing action `start` on resource 'service[mongos]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /etc/init.d/mongos start ----
STDOUT: Starting mongos: [FAILED]
@letz
letz / gist:fc5eefed82ebad75e77b
Created May 6, 2015 08:25
Create class dynamically
# Create Object dynamically
klass = Object.const_set 'DynamicWorker', Class.new
klass.redefine_method(:perform) { |*args| }
klass.include Sidekiq::Worker

Keybase proof

I hereby claim:

  • I am letz on github.
  • I am letz (https://keybase.io/letz) on keybase.
  • I have a public key whose fingerprint is 6759 8FE9 DCD3 6A90 79B8 30C9 E55E 05AE 5852 6CB2

To claim this, I am signing this object: