Skip to content

Instantly share code, notes, and snippets.

View hermitbaby's full-sized avatar

Jack Chen hermitbaby

View GitHub Profile
#!/bin/bash
prefix=foovar
aws apigateway get-rest-apis | jq "(.items | map(select(.name | startswith(\"${prefix}-\"))))"
# extract ids only
aws apigateway get-rest-apis | jq "(.items | map(select(.name | startswith(\"${prefix}-\")))) | .[].id"
@facholi
facholi / index.js
Created September 16, 2016 20:35
Node.js script to runs on AWS Lambda. Converts the PDF pages to JPG images
var async = require("async");
var AWS = require("aws-sdk");
var gm = require("gm").subClass({imageMagick: true});
var fs = require("fs");
var mktemp = require("mktemp");
var PAGE_WIDTH = 1300,
PAGE_HEIGHT = 1300;
var utils = {
@btfak
btfak / useHexo.md
Created May 26, 2016 09:41
How to use Hexo and deploy to GitHub Pages
const Promise = require('bluebird');
const crypto = Promise.promisifyAll(require('crypto'));
const argon = Promise.promisifyAll(require('argon2-ffi').argon2i);
const securePassword = (rawPassword) => {
crypto.randomBytes(16, (err, salt) => {
if (err) throw err;
argon.hash(rawPassword, salt, (err, hash) => {
@davidbradway
davidbradway / markdown.md
Created January 25, 2015 23:52
Markdown Syntax Example from Mou

Mou

Mou icon

Overview

Mou, the missing Markdown editor for web developers.

Syntax

@rhuss
rhuss / docker-enter.sh
Last active August 29, 2015 14:05
nsenter with boot2docker
#!/bin/sh
usage ()
{
cat <<EOF
docker-enter -- Enter a running container via boot2docker and nsenter
Usage: docker-enter <container_name_or_ID> [command]
See https://github.com/jpetazzo/nsenter for details.
@selfboot
selfboot / quick_sort.py
Created July 27, 2014 04:29
快速排序的python实现
#! /usr/bin/env python
# -*- coding: utf-8 -*-
def quick_sort(sequence, start_index, end_index):
# print sequence
if start_index < end_index:
main_element = partition(sequence, start_index, end_index)
# print main_element
quick_sort(sequence, start_index, main_element-1)
@makenova
makenova / Difference between debounce and throttle.md
Last active February 22, 2023 03:09
Javascript function debounce and throttle

Difference between Debounce and Throttle

Debounce

Debounce a function when you want it to execute only once after a defined interval of time. If the event occurs multiple times within the interval, the interval is reset each time.
Example A user is typing into an input field and you want to execute a function, such as a call to the server, only when the user stops typing for a certain interval, such as 500ms.

Throttle

@postrational
postrational / gunicorn_start.bash
Last active April 4, 2024 12:48
Example of how to set up Django on Nginx with Gunicorn and supervisordhttp://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
#!/bin/bash
NAME="hello_app" # Name of the application
DJANGODIR=/webapps/hello_django/hello # Django project directory
SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket
USER=hello # the user to run as
GROUP=webapps # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use
DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name
@rudyryk
rudyryk / gist:4190318
Created December 2, 2012 18:24
Override delete_selected in Django admin
from django.core.exceptions import PermissionDenied
from django.contrib import admin
from django.contrib.admin.actions import delete_selected as delete_selected_
def delete_selected(modeladmin, request, queryset):
if not modeladmin.has_delete_permission(request):
raise PermissionDenied
if request.POST.get('post'):
for obj in queryset: