Skip to content

Instantly share code, notes, and snippets.

View synsa's full-sized avatar

Steve Lang synsa

View GitHub Profile
@synsa
synsa / .BASH-PROMPT.png
Created June 28, 2019 22:00 — forked from kfcobrien/.BASH-PROMPT.png
Clean informative bash prompt with git info
.BASH-PROMPT.png
@synsa
synsa / jsonToSqlite.py
Created July 15, 2019 19:09 — forked from atsuya046/jsonToSqlite.py
create sqlite database file from json file
# -*- coding:utf-8 -*-
import json
import sqlite3
JSON_FILE = "some.json"
DB_FILE = "some.db"
traffic = json.load(open(JSON_FILE))
conn = sqlite3.connect(DB_FILE)
@synsa
synsa / config
Created August 6, 2019 19:51 — forked from MeanEYE/config
i3 config
# set modifier to Super key
set $mod Mod4
# workspaces
set $ws_chat 1: Chat
set $ws_web 2: Web
set $ws_code 3: Code
set $ws_misc 4: Misc
set $ws_fm 5: FM
@synsa
synsa / ruby_csr_example.rb
Created August 16, 2019 17:17 — forked from mitfik/ruby_csr_example.rb
Ruby example of CSR with openssl
require 'openssl'
def gen_key(name)
key = OpenSSL::PKey::RSA.new 1048
file = File.new(name, "w")
file.write(key)
file.close
end
def get_key(name)
@synsa
synsa / install-comodo-ssl-cert-for-nginx.rst
Created August 20, 2019 20:58 — forked from bradmontgomery/install-comodo-ssl-cert-for-nginx.rst
Steps to install a Comodo PositiveSSL certificate with Nginx.

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@synsa
synsa / clean_html.php
Created August 27, 2019 17:49 — forked from xeoncross/clean_html.php
Sanitize HTML using PHP and the DOMDocument
<?php
/**
* Clean HTML string removing all element attributes and elements which are
* not in the provided whitelist (but keeping their allowed children).
*
* @see https://github.com/alixaxel/phunction/blob/master/phunction/HTML.php
* @param string $html to clean
* @param array $whitelist
*/
function clean_html($html, array $whitelist)
@synsa
synsa / live_database_dump.rb
Created August 27, 2019 19:18 — forked from njakobsen/live_database_dump.rb
Live stream a database dump (or any other STDOUT) using Rails 4. Why would you want this? If you have a large database dump and want to avoid storing it in memory as Rails streams it. This allows pipe the dump directly into the http response instead of storing it as a file, sending it, and then deleting it. Let me know what you think! I've teste…
class DatabaseController < ApplicationController
def database_dump
database = Rails.configuration.database_configuration[Rails.env]["database"]
send_file_headers!(:type => 'application/octet-stream', :filename => "#{database}_#{Time.now.to_s(:human)}.backup")
pipe = IO.popen("pg_dump '#{database}' -F c")
stream = response.stream
while (line = pipe.gets)
stream.write line
sleep 0.0001 # HACK: Prevent server instance from sleeping forever if client disconnects during download
@synsa
synsa / LICENSE
Created September 4, 2019 22:46 — forked from sinisterchipmunk/LICENSE
tar, gzip, and untar files using ruby in memory without tempfiles
Copyright (C) 2011 by Colin MacKenzie IV
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@synsa
synsa / deploy.rb
Created October 4, 2019 04:57 — forked from noma4i/deploy.rb
Deploy Phoenix Elixir by mina
require 'mina/bundler'
require 'mina/git'
require 'mina/rbenv'
set :domain, 'your_domain.com'
set :deploy_to, '/home/deployer/app_name'
set :repository, '[email protected]:user_name/app_name'
set :branch, ENV["brunch"] || 'master'
set :app_name, "app_name"
<?php
/**
* Sanitiza los HTML retirando script tags del codigo
* @param $html string cadena HTML a sanitizar
* @return string retorna cadena sanitizada
*/
public static function sanitize_html($html){
$dom = new DOMDocument();
$dom->loadHTML($html);
$script = $dom->getElementsByTagName('script');