Skip to content

Instantly share code, notes, and snippets.

View xaviervia's full-sized avatar

Fernando Via Canel xaviervia

View GitHub Profile
@xaviervia
xaviervia / gist:6087296
Last active January 22, 2024 13:23
Reading the output from a shell command in Objective-C
- (void) doIt {
// Define the command name and the arguments array (the nil at the end is needed)
NSArray *arguments = [NSArray arrayWithObjects:@"--some-argument", @"--another", nil];
NSString *command = @"do-something-shell";
// Setup the NSTask for the command execution
NSTask *task = [[NSTask alloc] init];
task.launchPath = command;
task.arguments = arguments;
@xaviervia
xaviervia / instructions.md
Created September 21, 2012 04:16
Ultra fast server setup with Node, CoffeeScript, Express and MongoDB

Minimal REST server with Node and MongoDB

  1. Install httpie
  2. Install node.js
  3. Paste those files into some folder
  4. Install CoffeeScript into node with npm install coffee
  5. Run the server coffee server.coffee

Use it

@xaviervia
xaviervia / README.md
Last active February 16, 2021 20:12
Sketch 43 files JSON types
@xaviervia
xaviervia / index.html
Created September 24, 2020 11:24
lights
<script src="./script.js"></script>
<!-- <script src="./test.js" type="module"></script> -->
<style> body { margin: 0 } </style>
<canvas />
// --- WASM COMMANDS
const WASM_BINARY_MAGIC = [0x00, 0x61, 0x73, 0x6d]
const WASM_BINARY_VERSION = [0x01, 0x00, 0x00, 0x00]
const HEADER = WASM_BINARY_MAGIC.concat(WASM_BINARY_VERSION)
const I32 = 0x7F
const I32_ADD = 0x6a
const SECTION_CODE_TYPE = 0x01
const SECTION_CODE_FUNCTION = 0x03
const SECTION_CODE_EXPORT = 0x07
@xaviervia
xaviervia / nginx-environment.md
Last active July 1, 2019 12:45
Nginx and Docker links with environment variables, a love story

How to add environment variables to nginx.conf

This is the hack approach to adding environment variables to the nginx configuration files. As with most Google results for this search, the reason is Docker.

The setup

I intended to deploy two Docker containers.

@xaviervia
xaviervia / client.js
Created June 17, 2015 17:19
Remote REPL with WebSockets
(function (window) {
'use strict'
var Socket = function (url) {
this.url = url || 'ws://localhost:10001'
this.connect()
}
Socket.prototype.connect = function () {
const R = require('ramda')
const args = [2, [1, 2, 3]]
const output = [[1, 2], [3]]
const whichRamdaFunctionShouldIUse = (args, output) => {
return Object.keys(R).filter((key) => {
if (typeof R[key] !== 'function') {
return false
}
data Alignment
= LeftAligned
| CenterAligned
| RightAligned
data FontLevel
= DisplayTitle
| BodyText
data Variant
@xaviervia
xaviervia / RiemannZeta.idr
Created November 4, 2017 16:54
Riemann 𝜻 function in Idris, quick and dirty implementation for the rationals that prints information on each iteration
riemannZeta : (s : Double) -> IO Double
riemannZeta s = riemannZetaStep s 1.0 0.0
where riemannZetaStep : (s : Double) -> (n : Double) -> (p : Double) -> IO Double
riemannZetaStep s n p =
do let currentPower = pow n s
let currentFraction = 1.0 / currentPower
let currentValue = currentFraction + p
putStrLn ("s " ++ show s)
putStrLn ("n " ++ show n)
putStrLn ("power " ++ show currentPower)