$ sudo npm install -g hexo-cli
$ hexo -v
hexo-cli: 0.1.9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) => { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /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) |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: |
NewerOlder
