Skip to content

Instantly share code, notes, and snippets.

@moehlone
moehlone / make_writable.js
Created March 17, 2016 08:27
Make JavaScript readonly propertys writable (example for overwriting navigator.userAgent; useful for unit tests -> browser detection)
/**
* Creates a read/writable property which returns a function set for write/set (assignment)
* and read/get access on a variable
*
* @param {Any} value initial value of the property
*/
function createProperty(value) {
var _value = value;
/**
area_data = {
'臺北市': [
'中正區', '大同區', '中山區', '萬華區', '信義區', '松山區', '大安區', '南港區', '北投區', '內湖區', '士林區', '文山區'
],
'新北市': [
'板橋區', '新莊區', '泰山區', '林口區', '淡水區', '金山區', '八里區', '萬里區', '石門區', '三芝區', '瑞芳區', '汐止區', '平溪區', '貢寮區', '雙溪區', '深坑區', '石碇區', '新店區', '坪林區', '烏來區', '中和區', '永和區', '土城區', '三峽區', '樹林區', '鶯歌區', '三重區', '蘆洲區', '五股區'
],
'基隆市': [
'仁愛區', '中正區', '信義區', '中山區', '安樂區', '暖暖區', '七堵區'
],
@mpneuried
mpneuried / Makefile
Last active April 29, 2025 08:09
Simple Makefile to build, run, tag and publish a docker containier to AWS-ECR
# import config.
# You can change the default config with `make cnf="config_special.env" build`
cnf ?= config.env
include $(cnf)
export $(shell sed 's/=.*//' $(cnf))
# import deploy config
# You can change the default deploy config with `make cnf="deploy_special.env" release`
dpl ?= deploy.env
include $(dpl)
#!/bin/bash
function gateFile(){
for file in $1
do
if [ -d "${file}" ]
then
gateFile "${file}/*"
fi
@inadarei
inadarei / minikube-sierra.md
Last active October 20, 2020 01:57
Minikube Setup: Docker for Mac / Sierra

Prerequisite: latest Docker for Mac on MacOS Sierra

$ brew update
$ brew install --HEAD xhyve
$ brew install docker-machine-driver-xhyve
$ sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
$ sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve

$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.18.0/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
@chrisdpa-tvx
chrisdpa-tvx / athena.rst
Last active March 20, 2022 06:28
Create an Athena database, table, and query

All Your Data Does Not Belong In a Database

Businesses are machines producing mountains of data about sales, usage, customer, costs, etc... Traditionally data processing is highly centralised with teams of staff and computer running hot a whirling ready to process. We can do better than moving the mountain of data into the corporate data machine - so long as that machinary is light enough to be moved to the data.

Don't move the mountain - Bring the processing to the data

We've had this problem; a huge directory of files in CSV format, conataining vital information for our business. But it's in CSV, requires analysis, and don't you don't feel like learning sed/grep/awk today - besides it's 2017 and no-one thinks those tools are easy to use.

@aaronanderson
aaronanderson / S3Util.java
Last active February 6, 2024 10:52
Workaround to create presigned S3 URL using the new aws-sdk-java-v2 library preview
//updated for 2.0.0-preview-11
import java.io.ByteArrayInputStream;
import java.net.URI;
import java.time.Duration;
import java.time.Instant;
import java.util.Optional;
import software.amazon.awssdk.auth.signer.AwsS3V4Signer;
import software.amazon.awssdk.auth.signer.internal.AwsSignerExecutionAttribute;
@danilkuznetsov
danilkuznetsov / Export data from H2 database into CSV
Last active June 14, 2023 00:23
Export data from H2 database into CSV
CALL CSVWRITE('/home/<user>/downloads/<table_name>'.csv', 'SELECT * FROM <table_name>', 'charset=UTF-8 fieldSeparator=;');
Without field delimiter "
CALL CSVWRITE('/home/<user>/downloads/<table_name>'.csv', 'SELECT * FROM <table_name>', 'charset=UTF-8 fieldSeparator=; fieldDelimiter=');
@abc873693
abc873693 / taiwan_districts.json
Last active March 24, 2025 08:20
台灣行政區郵遞區號 JSON
[
{
"districts": [
{
"zip": "100",
"name": "中正區"
},
{
"zip": "103",
"name": "大同區"
@leek
leek / _Magento2_DeleteTestData.md
Last active March 27, 2025 06:52
Magento 2 - Delete All Test Data

These set of scripts are for Magento 2. For Magento 1, see this Gist.