You could do this with a 1-liner, but I'm going to try to explain the different parts (especially AJAX/callbacks) because they're complicated and interesting.
This is similar to other event handlers you've probably seen:
import { createStore } from '@stencil/store'; | |
export type Dispatch<T> = (value: T) => void; | |
export type Updater<T> = (value: T) => T; | |
export type Mutater<T> = (value: T) => void; | |
export interface Readable<T> { | |
subscribe: (subscription: Dispatch<T>) => void; | |
get: T; // fancy observer shit | |
} |
#!/usr/bin/env node | |
const process = require("process"); | |
const fetch = require("node-fetch"); | |
if (process.argv.length < 3 || process.argv.length > 4) { | |
console.error(`Usage: ${process.argv[0]} endpoint timeout`); | |
process.exit(2); | |
} | |
const endpoint = process.argv[2]; |
Check out Google Apps Script. Click "Start scripting", and it should bring you to a google-docs-esque text editor.
The gist of it is: You implement either a function doGet(e)
or a function doPost(e)
.
This function will be run when an HTTP request hits the google script's URL.
# Clear existing task so we can replace it rather than "add" to it. | |
Rake::Task["deploy:compile_assets"].clear | |
namespace :deploy do | |
desc 'Compile assets' | |
task :compile_assets => [:set_rails_env] do | |
# invoke 'deploy:assets:precompile' | |
invoke 'deploy:assets:precompile_local' | |
invoke 'deploy:assets:backup_manifest' |
private HashMap<String, String> parseObject(String jsonObject) { | |
HashMap<String, String> ret = new HashMap<String, String>(); | |
int arrayDepth = 0, objDepth = 0; | |
boolean inQuotes = false; | |
String currentKey = ""; | |
String currentElement = ""; | |
for (int i = 0; i < jsonObject.length(); i++) { | |
char ci = jsonObject.charAt(i); |
states = ['start'] | |
transitions = [] | |
final_states = [] | |
simple_symbols = '()[]{}!=<>+-*/%;&,'.split('') | |
special_symbols = [">=", "<=", "==", "!="] | |
alpha = ('A'.ord .. 'Z'.ord).map(&:chr) + ('a'.ord .. 'z'.ord).map(&:chr) | |
numeric = (1..9).map(&:to_s) | |
alphabet = alpha + numeric + simple_symbols + ['0'] | |
stupid_symbols = ['!'] |
:shipit:
=>
require 'json' | |
first = JSON.parse File.read 'first.json' | |
second = JSON.parse File.read 'second.json' | |
third = JSON.parse File.read 'third.json' | |
categories = [] | |
first['filterElementCommands'].each_with_index do |top_level_category_info, index| | |
top_category = { info: top_level_category_info } |
#include <vector> | |
#include <iostream> | |
using namespace std; | |
vector<int> factorize(int num){ | |
int smallest_pairing = num; | |
vector<int> factors; | |
for(int i=1; i<smallest_pairing; i++) | |
{ |