Skip to content

Instantly share code, notes, and snippets.

View 400.html
<!doctype html>
<html>
<title>400 Error</title>
<style>
body{text-align:center;position:absolute;width:100%;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);-moz-transform:translate(-50%,-50%);transform:translate(-50%,-50%);}
h2,h3{color:#555;font:bold 200%/100px sans-serif;margin:0}
h3,p{color:#777;font:normal 150% sans-serif}
p{font-size: 100%;font-style:italic;margin-top:2em;}
</style>
<h2>we didn't understand the request</h2>
View gist:45f00ce3e03ddc2b24bf
https://api.instagram.com/oauth/authorize/?client_id=[client_id]&redirect_uri=[redirect_uri]&response_type=code
curl -F 'client_id=[client_id]' -F 'client_secret=[client_secret]' -F 'grant_type=authorization_code' -F 'redirect_uri=[redirect_url]' -F 'code=[code]' https://api.instagram.com/oauth/access_token
View gist:9987966

on the server

sudo openssl genrsa -des3 -out server.key 2048
openssl req -new -key server.key -out server.csr

Country Name (2 letter code) [AU]:US

@saetia
saetia / gist:8570871
Last active Jan 4, 2016
Mysql triggers
View gist:8570871
CREATE TRIGGER `pages_created_at` BEFORE INSERT ON `pages` FOR EACH ROW SET NEW.created_at = UTC_TIMESTAMP(), NEW.updated_at = UTC_TIMESTAMP(), NEW.deleted_at = IF(NEW.deleted_at = "0000-00-00 00:00:00", NULL, NEW.deleted_at)
CREATE TRIGGER `pages_updated_at` BEFORE UPDATE ON `pages` FOR EACH ROW SET NEW.updated_at = UTC_TIMESTAMP(), NEW.created_at = OLD.created_at, NEW.deleted_at = IF(NEW.deleted_at = "0000-00-00 00:00:00", NULL, NEW.deleted_at)
View docker help
docker ps -a
docker logs 6238c4b20e4c
cd /var/lib/dokku/plugins
git clone https://github.com/Kloadut/dokku-pg-plugin postgresql
dokku plugins-install
dokku postgresql:create Joel
@saetia
saetia / web_image.rb
Last active Mar 22, 2019
Save web image as wallpaper
View web_image.rb
#/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open('https://medium.com'))
urls = doc.at_css('.cover-img')["style"].scan(/\('([^\)]*)'\)/)
image_src = 'http:'+urls[0][0]
ext = image_src.split('.').last
random = rand(2**256).to_s(36)[0..7]
download_path = "/tmp/#{random}.#{ext}"
View findin.sh
#!/bin/bash
if [ $# -eq 0 ]; then
echo -e "Usage: $0 site.com \033[32m'alert'\033[0m js"
exit
fi
if [ ! -d /var/www/${1}/public ]; then
echo -e "\033[31mfailed:\033[0m ${1} does not exist"
exit
View helm.php
#!/usr/bin/php -q
<?
chdir(__DIR__);
define('VERSION','0.6.5');
define("SITES_PATH",reset(explode(basename(__DIR__),__DIR__)));
define("DB_PW",generate_pw());
define("FTP_PW",generate_pw());
define("EMAIL_PW",generate_pw());
define("FINGERPRINT",strtoupper(generate_pw(20)));
define("DEVELOPER",trim(get_current_user()));
@saetia
saetia / post-commit
Last active Dec 20, 2015
optimize files after git push
View post-commit
#!/bin/sh
files="$(find -L . -name "*.js" -type f)"
echo "Scripts to minify: $(echo -n "$files" | wc -l)"
echo "$files" | while read file; do
uglifyjs "$file" -o "$file" -c -m
done
files="$(find -L . -name "*.css" -type f)"
echo "Stylesheets to minify: $(echo -n "$files" | wc -l)"
echo "$files" | while read file; do
View search.php
<? $lines = explode("\n",shell_exec("find ~/vhosts -name '*.md' -type f -print0 | xargs -0 fgrep ".escapeshellarg(params('search'))));?>
found <?=pluralize(count($lines),'results')?> for “<?=h(params('search'))?>
<? foreach ($lines as $l){
$e = explode('.md:',$l);
$path = basename(reset($e));
$excerpt = end($e); ?>
<li><?=highlight(h(strip_tags(markdown($excerpt))),params('search'))?> – <a href="/doc/<?=$path?>"><?=humanize($path)?></a></li>
<? } ?>
You can’t perform that action at this time.