Skip to content

Instantly share code, notes, and snippets.

View ikhanhmai's full-sized avatar
🎯
Focusing

Khanh Mai ikhanhmai

🎯
Focusing
View GitHub Profile
@ikhanhmai
ikhanhmai / dataURItoBlob.js
Created September 22, 2019 10:37
dataURItoBlob
dataURItoBlob = (dataURI) => {
// convert base64 to raw binary data held in a string
// doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this
var byteString = atob(dataURI.split(',')[1]);
// separate out the mime component
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]
// write the bytes of the string to an ArrayBuffer
var ab = new ArrayBuffer(byteString.length);
@vsviridov
vsviridov / 01_add_cors.config.yaml
Created September 5, 2015 05:45
Add CORS to Nginx on AWS Elastic Beanstalk
container_commands:
01_fix_static_cors:
command: "/tmp/fix_static_cors.sh"
files:
"/tmp/fix_static_cors.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active July 22, 2024 09:57
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'