Skip to content

Instantly share code, notes, and snippets.

@sebmarkbage
sebmarkbage / Enhance.js
Last active January 31, 2024 18:33
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
/* global Application, ObjC, $ */
/**
* repozish.js
*
* this is an example of using os x yosemite's "JavaScript for Automation":
*
* https://developer.apple.com/library/prerelease/mac/releasenotes/interapplicationcommunication/rn-javascriptforautomation/index.html
*
* it repositions some windows based on some position settings. you can run
var spawn = require('child_process').spawn,
sys = require('sys');
function createSSH(passphrase, path, name) {
var ssh = spawn('ssh-keygen', ['-trsa', '-N \''+ passphrase +'\'', '-f ' + name], { cwd:path, env: process.env, customFds: [-1, -1, -1]})
ssh.on('exit', function (code, signal) {
process.exit();
});
@dabing1022
dabing1022 / GetDeviceInfo.mm
Last active May 22, 2022 06:57
IOS_GET_DEVICE_INFO
NSLog(@"HostName: %@", [[NSProcessInfo processInfo] hostName]);
//globallyUniqueString 唯一的标示符,每次调用都会不一样,可以用作一些临时缓存文件的名字
NSLog(@"GlobalUniqueString: %@", [[NSProcessInfo processInfo] globallyUniqueString]);
//操作系统名称
NSLog(@"OperatingSystemName: %@", [[NSProcessInfo processInfo] operatingSystemName]);
//操作系统版本
NSLog(@"OperatingSystemVersion: %@", [[NSProcessInfo processInfo] operatingSystemVersionString]);
//物理内存
NSLog(@"PhysicalMem: %llu", [[NSProcessInfo processInfo] physicalMemory]);
//进程名称
@guptag
guptag / Q.js Examples
Last active April 4, 2021 06:22
Q.js examples - Small snippets to understand various api methods in Q.js
//To run Q.js examples:
// 1. Open a new browser tab in Chrome and turn on developer toolbar (or open any http site).
// 2. Copy/Paste this gist in the console and hit enter to run the snippets.
// Based on the inspiration from samples @ https://github.com/kriskowal/q
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
@wsargent
wsargent / docker_cheat.md
Last active August 31, 2023 12:10
Docker cheat sheet
@jgornick
jgornick / closure.sql
Created October 18, 2013 22:11
SQL: Closure Table Scripts
SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE IF EXISTS comments;
DROP TABLE IF EXISTS comment_paths;
CREATE TABLE comments (
comment_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY(comment_id)
);
@legastero
legastero / prosody-setup.lua
Last active February 24, 2019 12:11
Set up a Prosody server to work with stanza.io/otalk (with websockets, mam, etc)
-- 1. apt-get install prosody-trunk
-- 2. Checkout prosody-modules on Google Code
-- 3. Move all modules to /usr/lib/prosody/modules
-- 4. Move the mod_smacks module to mod_smacks2 and copy it to mod_smacks3
-- 5. Move the files in mod_smacks* to match the new names
-- 6. In mod_smacks3/mod_smacks3.lua s/urn:xmpp:sm:2/urn:xmpp:sm:3/g
-- 7. Set the Prosody configuration to:
admins = { "ADMIN@HOST" }
daemonize = true
@mikesname
mikesname / GraphGist-SimpleRBAC.adoc
Last active March 22, 2022 15:40
Very simplistic way of doing role-based access control (RBAC) with Neo4j.

This is a very simple approach to doing role-based access control with Neo4j. It is optimistic, in the sense that all items are assumed to be world-readable unless they have specific constraints. Item visibility can be constrained to either individual users or all users who belong to a role. Roles are also hierarchical, so can inherit privileges from other roles.

First, lets create our basic example data:

@bendo01
bendo01 / php56 macports
Last active April 10, 2018 22:55
php macports
sudo port install php56 +fastcgi fcgi apache-ant php56-cgi php56-mbstring php56-curl php56-mcrypt php56-imagick php56-xdebug php56-iconv php56-mongo php56-oauth php56-openssl php56-esmtp php56-pop3 php56-tidy php56-uploadprogress php56-pcntl php56-sockets php56-soap php56-ssh2 php56-big_int php56-gd php56-svm php56-html_parse php56-http php56-mysql php56-pdflib php56-pear php56-peb php56-posix php56-pspell php56-rar php56-redis php56-snmp php56-stomp php56-svn php56-wddx php56-xmlrpc php56-yaml php56-zip php56-dbase php56-excel php56-gdchart php56-imap php56-xsl php56-redis
sudo port install postgresql94 postgresql94-server postgresql94-doc postgresql_autodoc php56-postgresql phppgadmin postgresql-jdbc phpmyadmin maven3 maven-ant-tasks postgis2 +postgresql94 git qgis re2c json-c
sudo port install nginx +flv +geoip +gzip_static +mail +mp4 +ssl +status +substitution +upload +upload_progress +xslt +zip