Skip to content

Instantly share code, notes, and snippets.

View gregorynicholas's full-sized avatar
💀
alter.

gregory nicholas gregorynicholas

💀
alter.
View GitHub Profile
@gregorynicholas
gregorynicholas / _verify-repair-permissions-disk.md
Created November 19, 2018 22:13 — forked from bzerangue/_verify-repair-permissions-disk.md
Mac OS X Utilities via Terminal: (Verify and Repair: Disk Permissions AND Disk / Software Update / TimeMachine)

Verify and Repair Disk Permissions via Terminal (Mac OS X)

Verify Permissions

diskutil verifyPermissions /

Repair Permissions

diskutil repairPermissions /

@gregorynicholas
gregorynicholas / com.apple.Boot.plist
Created November 17, 2018 11:08 — forked from tjluoma/com.apple.Boot.plist
Enable the "Apple MacBook Air SuperDrive" on any Mac
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Kernel Flags</key>
<string>mbasd=1</string>
</dict>
</plist>
# coding=UTF-8
import nltk
from nltk.corpus import brown
# This is a fast and simple noun phrase extractor (based on NLTK)
# Feel free to use it, just keep a link back to this post
# http://thetokenizer.com/2013/05/09/efficient-way-to-extract-the-main-topics-of-a-sentence/
# Create by Shlomi Babluki
# May, 2013
@gregorynicholas
gregorynicholas / example-advanced.html
Created August 8, 2018 16:27 — forked from dvnkshl/example-advanced.html
Commerce.js Checkout (Advanced)
<!---
This is a advanced javascript checkout built with Commerce.js (http://commercejs.com).
Tutorial: Checkout Tutorial (Advanced) - http://commerce.js.com/docs/overview/checkout-tutorial-advanced/
!-->
<html>
<head>
<title>Checkout Tutorial (Advanced)</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.serializeJSON/2.7.2/jquery.serializejson.js"></script>
<script type="text/javascript" src="https://chec-cdn.s3.amazonaws.com/js/commerce.js"></script>
// https://m.cafe.naver.com/eojji/302
// unit: msec
function timeCheck(startTime, needTime) {
var nowDate = new Date();
// remain = 6 min - ( now - start )
var remain = 360000 - (nowDate.getTime() - startTime);
if (remain < needTime) {
return false;
} else {
return true;
// https://m.cafe.naver.com/eojji/307
function setPageTokenProperty(value) {
PropertiesService.getUserProperties().setProperty('PAGE_TOKEN', value);
}
function getPageTokenProperty() {
var pageTokenProperty = PropertiesService.getUserProperties().getProperty('PAGE_TOKEN');
return pageTokenProperty;
}
@gregorynicholas
gregorynicholas / how-to-use-aws-elasticsearch.md
Created June 19, 2018 18:46 — forked from simonw/how-to-use-aws-elasticsearch.md
How to use Amazon AWS Elasticsearch

How to use Amazon AWS Elasticsearch

The good news: you can get it running on the free tier (with a tiny instance).

The bad news: it's stuck on Elasticsearch 1.5.2 and dynamic scripting (Groovy) is disabled.

http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/aes-limits.html

Authentication: the safest option is to create a brand new IAM user (using the tool at https://console.aws.amazon.com/iam/home?region=us-east-1 ) with its own access key and secret key. Then when you create the Elasticsearch instance you can paste in the following IAM string:

@gregorynicholas
gregorynicholas / csv_example.py
Created June 19, 2018 18:46 — forked from simonw/csv_example.py
Here's how to use Python to output an Excel-compatible CSV (actually TSV) file from a command-line script. You can then use this pattern: "python csv_example.py | pbcopy" to copy the output to your clipboard, then just focus on a cell in Excel or Google Sheets and hit "paste" to copy the data into a bunch of cells.
import csv, sys
def fetch_data():
# Returning some example data - hit a JSON API or something here
return [{
"name": "Name 1",
"age": 32,
"description": "Look, we can use commas and\ttabs & stuff in here!",
}, {
"name": "Name 2",
@gregorynicholas
gregorynicholas / websse.py
Created June 19, 2018 18:43 — forked from werediver/websse.py
Simple demonstration of how to implement Server-sent events (SSE) in Python using Bottle micro web-framework. SSE require asynchronous request handling, but it's tricky with WSGI. One way to achieve that is to use gevent library as shown here.
"""
Simple demonstration of how to implement Server-sent events (SSE) in Python
using Bottle micro web-framework.
SSE require asynchronous request handling, but it's tricky with WSGI. One way
to achieve that is to use gevent library as shown here.
Usage: just start the script and open http://localhost:8080/ in your browser.
Based on:
@gregorynicholas
gregorynicholas / elasticsearch_dsl_facet_override.py
Created June 19, 2018 18:43 — forked from simonw/elasticsearch_dsl_facet_override.py
Over-riding elasticsearch-dsl FacetedSearch to use .filter, not .post_filter for selected facets - see https://twitter.com/simonw/status/797894804700966912
class EmailSearch(FacetedSearch):
doc_types = [Email]
# fields that should be searched
fields = ['subject', 'body']
facets = {
'inbox': TermsFacet(field='inbox'),
}
def filter(self, search):