Skip to content

Instantly share code, notes, and snippets.

View vinta's full-sized avatar
🩸
爛命一條

Vinta Chen vinta

🩸
爛命一條
View GitHub Profile
@lolzballs
lolzballs / HelloWorld.java
Created March 22, 2015 00:21
Hello World Enterprise Edition
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
public class HelloWorld{
private static HelloWorld instance;
public static void main(String[] args){
instantiateHelloWorldMainClassAndRun();
@tzangms
tzangms / s3sqlbackup.sh
Last active August 29, 2015 14:06
Backup MySQL to S3
#!/bin/sh
export MYSQL_HOST=<your-mysql-host>
export MYSQL_USER=<your-mysql-username>
export MYSQL_PASSWORD=<your-mysql-password>
export NAME=<name-of-backup>
export DATE=`date +"%Y%m%d"`
export BACKUP_FILE=$NAME.$DATE.sql.gz
export DATABASE_SCHEMA_NAME=<database-name>
export S3_BUCKET=<s3-bucket-name>
@maephisto
maephisto / Javascript ISO country code to country name conversion
Last active August 15, 2024 03:08
ISO 3166-1 alpha-2 country code to country name conversion with a simple Javascript implementation, an array and a function.
var isoCountries = {
'AF' : 'Afghanistan',
'AX' : 'Aland Islands',
'AL' : 'Albania',
'DZ' : 'Algeria',
'AS' : 'American Samoa',
'AD' : 'Andorra',
'AO' : 'Angola',
'AI' : 'Anguilla',
'AQ' : 'Antarctica',
@wancw
wancw / ls-migrations-then-checkout
Last active December 16, 2016 18:55
列出切換 branch 前需要 rollback 的 South migration。
#!/usr/bin/env zsh
if [[ $# != 1 ]]; then
cat - << USAGE
Usage: `basename $0` <branch>
USAGE
return 1
fi
local old_branch=$(git rev-parse --abbrev-ref HEAD)
@sloria
sloria / bobp-python.md
Last active April 27, 2025 07:06
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@plentz
plentz / nginx.conf
Last active May 3, 2025 05:27
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@nicolashery
nicolashery / elasticsearch.md
Last active December 30, 2023 19:03
Elasticsearch: updating the mappings and settings of an existing index

Elasticsearch: updating the mappings and settings of an existing index

Note: This was written using elasticsearch 0.9.

Elasticsearch will automatically create an index (with basic settings and mappings) for you if you post a first document:

$ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \
'{
  "_id": 1,
@ionelmc
ionelmc / profiled_decorator.py
Last active February 19, 2017 09:49
Profiling decorator that generates kcachegrind output.
import cProfile
import os
import pstats
import time
from datetime import datetime
from functools import wraps
from io import StringIO
from logging import getLogger
logger = getLogger(__name__)
@garethrees
garethrees / gist:5591027
Last active October 14, 2020 19:44
Ansible set timezone on Ubuntu host
- name: Group by Distribution
hosts: all
tasks:
- group_by: key=${ansible_distribution}
- name: Set Time Zone
hosts: Ubuntu
gather_facts: False
tasks:
- name: Set timezone variables
@ju-popov
ju-popov / timestamp.py
Last active April 7, 2021 16:09
Python DateTime / Timestamp Convertion
######################################################################
# CURRENT AWARE LOCAL DATETIME
######################################################################
from datetime import datetime
from tzlocal import get_localzone
local_tz = get_localzone()
local_dt = datetime.now(local_tz)