Skip to content

Instantly share code, notes, and snippets.

View haozes's full-sized avatar

haozes haozes

View GitHub Profile
@ryanflorence
ryanflorence / static_server.js
Last active July 21, 2024 12:43
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
// See http://stackoverflow.com/questions/21934831/nodejs-express-stream-stdout-instantly-to-the-client
var cp = require("child_process"),
express = require("express"),
app = express();
app.get('/', function(req, res){
res.writeHead(200, { "Content-Type": "text/event-stream" });
@Timopheym
Timopheym / sync_pins.js
Last active September 9, 2023 17:09
Small script to download your pinterest boards to your machine. Limit 50 pins per board... but you can download all pins from board using instruction inside ;)
var request = require("request");
var fs = require("fs");
var api_root = 'http://widgets.pinterest.com/v3/pidgets/boards/';
var sync_dir = './images', image_url, image_path, current_user_boards, current_user_name, board_dir;
var users = {
timopheym : [
'skatches',
'home',
@spllr
spllr / cloudkit-request.js
Last active August 28, 2023 12:04
Setting up an authenticated CloudKit server-to-server request
/**
* Demonstrates how to use Apple's CloudKit server-to-server authentication
*
* Create private key with: `openssl ecparam -name prime256v1 -genkey -noout -out eckey.pem`
* Generate the public key to register at the CloudKit dashboard: `openssl ec -in eckey.pem -pubout`
*
* @see https://developer.apple.com/library/prerelease/ios/documentation/DataManagement/Conceptual/CloutKitWebServicesReference/SettingUpWebServices/SettingUpWebServices.html#//apple_ref/doc/uid/TP40015240-CH24-SW6
*
* @author @spllr
*/
@leizongmin
leizongmin / createPromiseCallback.js
Last active December 20, 2017 03:40
兼容Promise的callback函数
function createPromiseCallback() {
const callback = (err, ret) => {
if (err) {
callback.reject(err);
} else {
callback.resolve(ret);
}
};
callback.promise = new Promise((resolve, reject) => {
callback.resolve = resolve;
@leilee
leilee / Install iOS Simulators in Xcode Manually.md
Last active May 15, 2024 01:03
Install iOS Simulators in Xcode Manually
  • Open Xcode -> Preferences -> Components.
  • Open the Console App, clear the console.
  • Go back to the Xcode preferences. Start the simulator download, then cancel it.
  • Now in the Console, you will see something about the cancellation with the download URL.
  • Copy the URL from the Console, download it.
  • Copy this file to ~/Library/Caches/com.apple.dt.Xcode/Downloads.
    • If Downloads did not exist, create a new Downloads directory.
    • If Downloads exists, remove all *.dvtdownloadableindex files under it.
  • Open Xcode -> Preferences -> Components, start the simulator download again, it should find the file you downloaded and install it.
@denisenepraunig
denisenepraunig / BreathAnimation.swift
Last active November 1, 2023 00:21
Apple Watch Breath Animation in SwiftUI - modified pink edition
//
// BreathAnimation.swift
// breathing-animation
//
// Created by Denise Nepraunig on 17.05.21.
//
// Code is based on this tutorial:
// https://www.youtube.com/watch?v=KUvkJOhpB9A
// Thanks Adam :-)