Skip to content

Instantly share code, notes, and snippets.

View kulicuu's full-sized avatar

J Wylie Кулик kulicuu

View GitHub Profile
@kulicuu
kulicuu / flame.lua
Last active August 26, 2015 16:39 — forked from joshski/flame.lua
Generates a little flame. Works in Codea.
-- a little flame in a functional style
function particle(step, style, t)
local newStyle = step(style, t)
return {
style = newStyle,
next = function()
return particle(step, newStyle, t + 1)
end
}
@kulicuu
kulicuu / SocketStreamExpress.iced
Last active August 29, 2015 14:00
essential elements of a SocketStream main app file that integrates Express within the Ss stack:
http= require 'http'
ss= require 'socketstream'
express= require 'express'
metro= express()
connectRedis= require 'connect-redis'
redisStore= connectRedis express
metro.use express.json()
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
@kulicuu
kulicuu / another.coffee
Last active August 29, 2015 14:08
translate arabic to roman numerals :: the boring and un-elegant way
c= console.log
c "another arabic to roman numeral translator: \n"
digitiser= (integra)->
if integra >= 10000 then c "error, we're only taking numbers less than 10,000"
strang= integra.toString()
rayy= strang.split ''
arq= {}
switch strang.length
when 4
@kulicuu
kulicuu / oct29.iced
Last active August 29, 2015 14:08
array manipulation exercises
# some array exercises around the codility exercise
c= console.log
# functions:
# 0- check if order is non decreasing
# 1- check if array can be made non-decreasing with just one swap. (or less)
# 2- getAll repeated element substrings (one black sheep allowed). this may not be helpful for finding (1), but it's a good exercise in itself
# possible algos approaches for finding (1)
# - if array small then could just go through all combos blindly and check if order is good. slightly better to only go through those swaps which transfer large to back of array and small to front.
@kulicuu
kulicuu / jan2_request.coffee
Last active August 29, 2015 14:12
life's simple pleasures
# jan2 request bluebird stuff
c= console.log
_= require 'lodash'
Promise= require 'bluebird'
rp= require 'request-promise'
qStr= require 'querystring'
parse_quals= (quals)->
return _.reduce quals,
(acc0, value, key)->
@kulicuu
kulicuu / stringhandler2.java
Created May 19, 2015 06:41
permutation thing in java did this some years ago
/**
* This
*/
import java.util.*;
public class StringHandler2{
//public ArrayList<String> arrayPurms = new ArrayList<String>();
public static ArrayList<String> SetPermute(HashSet <String> resultSet){
System.out.println("We're in SetPermute. With argument " + resultSet.toString());
ArrayList <String> arrayPurms = new ArrayList <String> ();
if (resultSet.size() == 1) {
c = ->
message = _.reduce arguments, (acc, item) ->
item = util.inspect item
cursor = JSON.stringify item
message += cursor + "\n"
return acc + message
, ""
fs.appendFile 'log.txt', message, (err) ->
@kulicuu
kulicuu / shunting.coffee
Last active November 2, 2015 08:21
researching the shunting algorithm , trying it out
c = -> console.log.apply console, arguments
c 'shunting '
random_expression_string_builder = (nn) ->
rayy_builder = (n) ->
operators = ['+', '-', '*', '/']
operands_rayy = []
operators_rayy = []
@kulicuu
kulicuu / 1.1.coffee
Last active November 2, 2015 14:03
problems from "Cracking the Coding Interview"
c = -> console.log.apply console, arguments
c 'cracking the coding interview questions chapter 1'
c "Implement an algoritm to determine if a string has all unique characters. What if you can not use additional data structures?\n \n"
allowed_chars= ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
get_random_in_range = (range) ->
# get random integer between 0 and (range - 1)