Skip to content

Instantly share code, notes, and snippets.

View nathanjohnson320's full-sized avatar
💭
I may be slow to respond.

Nathaniel Johnson nathanjohnson320

💭
I may be slow to respond.
View GitHub Profile
var http = require('http');
var server = http.createServer( function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end("Hello, World!");
}).listen(process.env port || 11111);
console.log("Server listening on port: " + server.address().port);
@nathanjohnson320
nathanjohnson320 / gist:7283784
Last active February 2, 2021 10:35
Use the Google Places API with node.js
exports.randeats = function(req, res){
var key = req.query.key;
var location = encodeURIComponent(req.query.location);
var radius = 16000;
var sensor = false;
var types = "restaurant";
var keyword = "fast";
var https = require('https');
var url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?" + "key=" + key + "&location=" + location + "&radius=" + radius + "&sensor=" + sensor + "&types=" + types + "&keyword=" + keyword;
@nathanjohnson320
nathanjohnson320 / PHP is weird
Last active December 29, 2015 08:19
Why PHP is weird
if ("false" == true) echo "true\n";
// => true
if ("false" == false) echo "true\n";
// => false
if ("false" == 0) echo "true\n";
// => true, wtf
if (false == 0) echo "true\n";
@nathanjohnson320
nathanjohnson320 / 7 Digit Pi lindrome
Last active August 29, 2015 14:04
Find 7 Digit Prime palindrome in Pi
pi <- read.csv("./pi.csv", header=FALSE, sep=" ")
dig <- 14000
pistr <- paste(c(pi[1,]$V2, ".", head(pi[-1,], dig-1)$V2), collapse="")
is.palindrome <- function (word) { identical(word, paste(rev(strsplit(word, "")[[1]]), collapse="")) }
is.prime <- function(n) n == 2L || all(n %% 2L:floor(sqrt(n)) != 0)
base <- 1
# Install elixir raspberry pi, from http://suranyami.com/post/80056047551/installing-elixir-on-raspberry-pi
# Add the new repo
sudo echo 'deb http://packages.erlang-solutions.com/debian wheezy contrib' >> /etc/apt/sources.list
# Get the key
wget http://packages.erlang-solutions.com/debian/erlang_solutions.asc
sudo apt-key add erlang_solutions.asc && rm erlang_solutions.asc
# Get erlang
# Elixir in 5 minutes
# To run this script, do elixir processes.exs
# Comments are made with the pound sign
# Strings are standard double quotes ""
# To write to the CLI you can use IO.puts or IO.write
IO.puts "Hello, world"
defmodule Adventof.Day1 do
defp direction("R", :north), do: :east
defp direction("R", :east), do: :south