Skip to content

Instantly share code, notes, and snippets.

View knightli's full-sized avatar

knightli knightli

  • Alibaba.inc
  • HangZhou
View GitHub Profile
@mzipay
mzipay / jsonp-proxy-request-interceptor.js
Last active May 19, 2021 09:34
AngularJS HTTP interceptor to work around CORS/JSONP problems
/**
* @license CC0 1.0 (http://creativecommons.org/publicdomain/zero/1.0/)
*
* The problem:
* You need to make a cross-domain request for JSON data, but the remote
* server doesn't send the necessary CORS headers, and it only supports
* simple JSON-over-HTTP GET requests (no JSONP support).
*
* One possible solution:
* Use 'jsonp-proxy-request-interceptor' to proxy the request through
'use strict';
var React = require('react');
// EXAMPLE:
//
// var ExampleComponent = React.createClass({
// render(): any {
// // Define the CSS content used by this component.
// var styleContent = `
@OlavHN
OlavHN / gist:ff73b104bb25e5e08a51
Last active June 28, 2017 19:27
React render to polymer components!
<!doctype html>
<html>
<head>
<!-- Web Component Polyfill for old browsers -->
<script src="https://www.polymer-project.org/platform.js"></script>
<!-- Release candidate of next React -->
<script src="http://fb.me/react-with-addons-0.12.0-rc1.js"></script>
<script src="http://fb.me/JSXTransformer-0.12.0-rc1.js"></script>
<!-- Import a web component -->
@fractaledmind
fractaledmind / Markdown2Evernote with AutoLinking to New Notes
Last active July 9, 2019 04:47
REQUIREMENTS: The Satimage osax plugin for Applescript, MultiMarkdown, and Evernote. This script accepts Markdown-styled text from the clipboard and converts it to HTML to create a new note in Evernote. This new version adds the feature of extracting [[double bracketed]] words and phrases and creating new notes for those phrases and embedding th…
property markdownloc : "/usr/local/bin/multimarkdown"
property tid : AppleScript's text item delimiters
set mdSource to the clipboard
if is_running("Evernote") = false then
tell application id "com.evernote.Evernote" to launch
tell application "System Events"
set visible of process "Evernote" to false
@fractaledmind
fractaledmind / Evernote2Markdown
Last active December 27, 2015 20:09
REQUIREMENTS --Satimage osax plugin for Applescript --Aaron Swartz's html2text python script --Evernote This script takes your currently selected Evernote note and generates a Markdown copy of it in your Documents folder. It will then automatically open the new Markdown text file and holds the Markdown itself in the clipboard.
(* EVERNOTE TO MARKDOWN
--Stephen Margheim
--11/9/13
--open source
REQUIREMENTS
--Satimage osax plugin
--Aaron Swartz's html2text python script
--Evernote
@fractaledmind
fractaledmind / Markdown2Evernote
Created November 9, 2013 08:06
REQUIREMENTS: MultiMarkdown, Evernote. This script accepts text from the clipboard in (Multi)Markdown format and passes it to Evernote as HTML. The script also accepts 3 lines of metadata: Title, Notebook, and Keywords.
property markdownloc : "/usr/local/bin/multimarkdown"
property tid : AppleScript's text item delimiters
set mdSource to the clipboard
--check for Title metadata
try
if text item 1 of paragraph 1 of mdSource = "#" then
if not text item 2 of paragraph 1 of mdSource = "#" then
set theTitle to text items 3 thru -1 of paragraph 1 of mdSource as string
@cowboy
cowboy / child-test.js
Created August 22, 2012 16:19
Node.js: I can't seem to capture a child process's stdout and stderr in Windows.
var parent = function() {
var spawn = require('child_process').spawn;
var child = spawn(process.execPath, [process.argv[1], 123]);
var stdout = '';
var stderr = '';
child.stdout.on('data', function(buf) {
console.log('[STR] stdout "%s"', String(buf));
stdout += buf;
});
child.stderr.on('data', function(buf) {