This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
generator = require('utf8-fdf-generator').generator; | |
generator({ myField01: "Gabriel Medina", myField02: "Ciudad Juárez, Chihuahua, México" }, "output.fdf"); | |
// Do whatever you need with file output.fdf here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
params = "token=palomitas"; | |
xmlhttp = new XMLHttpRequest(); | |
xmlhttp.onreadystatechange = function() { | |
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { | |
document.getElementById("mydiv").innerHTML = xmlhttp.responseText; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A simple hello world microservice | |
// Click "Deploy Service" to deploy this code | |
// Service will respond to HTTP requests with a string | |
module['exports'] = function helloWorld (hook) { | |
// hook.req is a Node.js http.IncomingMessage | |
var host = hook.req.host; | |
// hook.res is a Node.js httpServer.ServerResponse | |
// Respond to the request with a simple string | |
hook.res.end(host + ' says, "Hello world, papanatas!"'); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.Console; | |
import java.io.IOException; | |
import java.io.Reader; | |
import java.lang.Runtime; | |
public class Main { | |
public static void main(String[] args) throws IOException, InterruptedException { | |
System.out.println("Press the \"z\" key to exit!"); | |
String[] cmd = {"/bin/sh", "-c", "stty raw </dev/tty"}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Mingles two strings | |
-- | |
-- INPUT "abcd\n1234\n" | |
-- OUTPUT "a1b2c3d4\n" | |
solve :: String -> String -> String | |
solve [] [] = [] | |
solve (x:xs) (y:ys) = x : y : solve xs ys | |
main :: IO () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Calculate the perimeter delineated by the list of points | |
-- | |
-- Input from standard in is as follows: | |
-- | |
-- 4 | |
-- 0 0 | |
-- 0 1 | |
-- 1 1 | |
-- 1 0 | |
-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Rotate Strings | |
import Data.List | |
rotate s r = drop r s ++ take r s | |
solve s = intercalate " " (tail rss ++ [ head rss ]) | |
where rss = [ rs | r <- [ 0 .. (length s - 1) ], let rs = rotate s r ] | |
main = do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---- Remove Duplicates and return characters in the order they were found | |
import Data.List | |
solve :: String -> String -> String | |
solve b "" = b | |
solve b (s:st) | |
| isInfixOf (s : "") b = solve b st | |
| otherwise = solve (s : b) st |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
solve n m = sum times | |
where oSize = fromIntegral $ n * m | |
oIndices = [ 1 .. oSize ] | |
singleProb = (\x -> x / oSize) | |
singleTime = (\n -> 1 / (singleProb n)) | |
times = map singleTime oIndices | |
main = do | |
raw <- readFile "input.txt" | |
let inStrArr = words $ head $ lines raw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.Map.Strict as MS | |
import Data.List | |
-- Basically a valid function is that which | |
-- always return the same output for a given input, | |
-- that is, a function that one time returns 3 for f(1) | |
-- and the next returns 5 for the same f(1) is NOT | |
-- a valid function | |
-- | |
-- This algorithm checks we have unique outputs for |