Skip to content

Instantly share code, notes, and snippets.

View goodfeel's full-sized avatar
:octocat:

Jesdakorn Samittiauttakorn goodfeel

:octocat:
View GitHub Profile
@goodfeel
goodfeel / bb-del.rb
Last active September 1, 2017 03:02
Mass Delete Bitbucket Repo via API
# You need to create Oauth consumer app here:
# https://bitbucket.org/account/user/<Your BB username>/api
# Or go to Bitbucket and Click no your user and click on BitBucket Settings
# Get the token by access:
# https://bitbucket.org/site/oauth2/authorize?client_id={client_id}&response_type=code
# On the URL Query string you should see the code
# Run curl -X POST -u "<OAuth App ID>:<OAuth App Secret>" https://bitbucket.org/site/oauth2/access_token -d grant_type=authorization_code -d code=<Code from previous step>
# Then you should get your token and replace that in the code. Don't forget to keep refresh token in case, you want to refresh it.
@goodfeel
goodfeel / cuda.md
Created May 3, 2017 04:14
Nvidia CUDA installation on Ubuntu 16.04

This done on Alienware PC

Step

  1. Install fresh 16.04TLS
  2. Download CUDA library (.run)
  3. Go to Terminal mode (Ctrl + Alt + F1)
  4. Stop lightdm (service lightdm stop)
  5. Chmod +x and run CUDA installer (sudo su ./cuda...run)
  6. It will fail due to Noveau thing so should restart and run step 5 again.
  7. Setup bash profile for PATH to include (/usr/local/cuda)
@goodfeel
goodfeel / gen.sh
Created August 1, 2016 08:34
HTTP Pinning Certificate Generate
openssl x509 -noout -in CERTNAME.crt -pubkey | \
openssl asn1parse -noout -inform pem -out public.key;
openssl dgst -sha256 -binary public.key | openssl enc -base64
@goodfeel
goodfeel / gist:14f99a44da3f228c1636
Created January 24, 2016 05:08 — forked from jberkus/gist:6b1bcaf7724dfc2a54f3
Finding Unused Indexes
WITH table_scans as (
SELECT relid,
tables.idx_scan + tables.seq_scan as all_scans,
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes,
pg_relation_size(relid) as table_size
FROM pg_stat_user_tables as tables
),
all_writes as (
SELECT sum(writes) as total_writes
FROM table_scans
@goodfeel
goodfeel / iap_check.rb
Created November 4, 2015 13:04
Apple IAP Sandbox Check
require 'json'
require 'net/https'
require 'uri'
data = "<based 64 reciept data>"
params = {
'receipt-data' => data
}.to_json
uri = URI('https://sandbox.itunes.apple.com/verifyReceipt')
@goodfeel
goodfeel / squid.conf
Created October 27, 2015 02:09 — forked from hpcorona/squid.conf
simple squid3 configuration to allow all to connect to all
#Recommended minimum configuration:
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8
acl localnet src 0.0.0.0/8 192.168.100.0/24 192.168.101.0/24
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
@goodfeel
goodfeel / nr-synthetics.js
Created July 29, 2015 02:15
NewRelic Synthetics API Test Script
/**
* Welcome to the Synthetics JavaScript IDE - API Edition
* You can think of it like node.js lite. Everything you'd expect to find in a
* node.js environment is also available here, with a few notable exceptions:
*
* Feel free to explore, or check out the full documentation
* https://docs.newrelic.com/docs/synthetics/new-relic-synthetics/scripting-monitors/writing-api-tests
* for details.
*/
@goodfeel
goodfeel / setup-swap.sh
Last active August 29, 2015 14:25
setup swap for aws ami
#!/bin/bash
sudo /bin/dd if=/dev/zero of=/var/swap1 bs=512M count=2
sudo /sbin/mkswap /var/swap1
sudo chmod 0600 /var/swap1
sudo /sbin/swapon /var/swap1
sudo echo "/var/swap1 swap swap defaults 0 0" >> /etc/fstab
sudo reboot now
To gen dhparam:
sudo openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@goodfeel
goodfeel / mysql_dump
Created May 21, 2015 01:20
mysqldump with query
mysqldump DATABASE --tables logs --where="created_at < '2015-03-01'" -u XXXX -pXXXXX --host ZZZZZZ.com > data.sql