Skip to content

Instantly share code, notes, and snippets.

View nanzhipro's full-sized avatar

南知 nanzhipro

View GitHub Profile
@jeserodz
jeserodz / mongo-express-config.js
Created January 22, 2016 14:22
Example config file for mongo-express
/*
This is an example config file for mongo-express (https://www.npmjs.com/package/mongo-express)
Should work without modifying if your mongodb server users are defaults
How to use:
1. Copy this file in your app/node_modules/mongo_express directory
2. Rename to config.js
*/
'use strict';
@christopher-baek
christopher-baek / .Setting Environment Variables in OS X Yosemite.md
Last active May 11, 2022 06:46
Setting Environment Variables in OS X Yosemite

Setting Environment Variables in OS X Yosemite

shell

  • Terminal apps in OS X (Terminal, iTerm, etc.) process terminals as login shells, so these variables should be set in the ~/.bash_profile and not the ~/.bashrc file.

system (including GUI apps)

  • Create a ~/Library/LaunchAgents/environment.variables.plist file to have launchd run a script at login that will set environment variables
  • Create a /usr/local/bin/set-environment-variables.sh script (or wherever configured in the *.plist file) and "export" the environment variables here (bash syntax like "export JAVA_HOME ..." doesn't work here)
  • Register the *.plist file with launchd
@kennwhite
kennwhite / vpn_psk_bingo.md
Last active April 5, 2025 04:55
Most VPN Services are Terrible

Most VPN Services are Terrible

Short version: I strongly do not recommend using any of these providers. You are, of course, free to use whatever you like. My TL;DR advice: Roll your own and use Algo or Streisand. For messaging & voice, use Signal. For increased anonymity, use Tor for desktop (though recognize that doing so may actually put you at greater risk), and Onion Browser for mobile.

This mini-rant came on the heels of an interesting twitter discussion: https://twitter.com/kennwhite/status/591074055018582016

Last updated: 2014-12-25

mdfind commands

Find all the file types in a given directory

mdfind -attr kMDItemContentType "kMDItemContentType == '*'" -onlyin . | awk -F"kMDItemContentType =" '{print $2}' | sort | uniq -c | sort -r

Get Last 5 Files Added in Dropbox Folders

@skazhy
skazhy / payload.xml
Last active March 15, 2022 05:47
Configuration profile example
<?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>PayloadIdentifier</key>
<string>com.fullcontact</string>
<key>PayloadType</key>
<string>Configuration</string>
@imcaspar
imcaspar / videocj.sh
Last active November 30, 2020 10:02
cut/join videos using ffmpeg without quality loss
#!/bin/bash
#cut/join videos using ffmpeg without quality loss
if [ "$(uname)" == "Darwin" ]; then
if ! [ -x "$(command -v brew)" ]; then
echo 'homebrew is not installed.'
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
if ! [ -x "$(command -v ffmpeg)" ]; then
echo 'ffmpeg is not installed.'
@i03nomura1y
i03nomura1y / ios_lockscreen_notification.m
Last active May 19, 2020 12:15
iOS LockScreen Notification
// iOS ロックスクリーン Notification
#define NotifName_LockComplete @"com.apple.springboard.lockcomplete"
#define NotifName_LockState @"com.apple.springboard.lockstate"
//call back
static void lockStatusChanged(CFNotificationCenterRef center, void *observer, CFStringRef name_cf, const void *object, CFDictionaryRef userInfo){
NSString *name = (__bridge NSString*)name_cf;
if ([name isEqualToString:NotifName_LockComplete]) {
@kkurahar
kkurahar / app.js
Last active October 11, 2016 14:24
Node.js + Express(Jade) + MongoDB(mongose + connect-mongo) でログイン認証機能を実装
/**
* Module dependencies.
*/
var express = require('express'),
routes = require('./routes'),
http = require('http'),
path = require('path'),
MongoStore = require('connect-mongo')(express);
@chinmaygarde
chinmaygarde / ScreenCapture.m
Created January 27, 2013 09:12
Mac OSX Screen Capture
CGImageRef imageRef = CGWindowListCreateImage(CGRectInfinite, kCGWindowListOptionAll, kCGNullWindowID, kCGWindowImageDefault);
CFMutableDataRef dataRef = CFDataCreateMutable(kCFAllocatorDefault, 0);
CGImageDestinationRef dest = CGImageDestinationCreateWithData(dataRef, kUTTypePNG, 1, NULL);
CGImageDestinationAddImage(dest, imageRef, NULL);
CGImageDestinationFinalize(dest);
CFRelease(dest);
CGImageRelease(imageRef);
@mattstevens
mattstevens / gist:4400775
Last active March 9, 2022 12:53
Resizing an NSImage on retina Macs for output as a 1x image
NSImage *computerImage = [NSImage imageNamed:NSImageNameComputer];
NSInteger size = 256;
NSBitmapImageRep *rep = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:size
pixelsHigh:size
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES