Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

import XCPlayground
import Foundation
import UIKit
import SpriteKit
var even = { x in x%2 == 0 }
var odd = { x in !even(x) }
var letters = Array("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
@homam
homam / apple-script-send-imessage.sh
Last active December 23, 2020 09:51
AppleScripts for sending iMessages and Attachment
osascript send-imessage.scpt "hello" "Homam Hosseini"
osascript send-imessage-pic.scpt `realpath northamerica-neb.jpg` "Homam Hosseini"
@homam
homam / Web-Rich-Media-Banners-API-Simple.md
Created September 8, 2014 07:38
Web Rich Media API - Simple

Web Rich Media Banners API

This API is going to be used in our Web Rich Media Banners. The purpose is to be able to support interstitial interactive banners and get subscribers directly from banners.

JSONP

The Request URL always contains Query String parameter: jsonp.

Response content-type must be: application/javascript.

@homam
homam / fast-json-csv.ls
Last active October 19, 2016 13:15
CLI tool for fast and hassle-free JSON to CSV conversion
#!/usr/local/bin/lsc -d
{foldl, Str, Obj, map} = require \prelude-ls
json-to-csv = (obj) ->
cols = obj.0 |> Obj.keys
(cols |> (Str.join \,)) + "\n" + do ->
obj
|> foldl do
(acc, a) ->
acc.push <| cols |> (map (c) -> a[c]) |> Str.join \,
@homam
homam / find-and-replace-all.ls
Created September 15, 2014 09:50
Find and Replace in String and Files in JavaScript
fs = require \fs
{map} = require \prelude-ls
{promises: {new-promise, parallel-limited-sequence, from-error-value-callback, from-void-callback, promise-monad}} = require \async-ls
find-and-repalce = (regex, replacement, file) -->
new-file = ""
last-index = 0
while m = regex.exec file
new-file := new-file + (file.substring last-index, m.index) + replacement m
@homam
homam / stats-test.ls
Last active August 29, 2015 14:07
Statistics, Probability, Confidence Interval
{sqrt} = require \prelude-ls
{
find-propability-of-population-mean-in-a-range-for-continuous-variable
find-confidence-interval-of-population-mean-for-continuous-variable
find-propability-of-population-mean-in-a-range-for-binomial-variable
find-confidence-interval-of-population-mean-for-binomial-variable
} = require \./stats
round = (precision, n) -->
tens = 10**precision
# *-state-maker :: (model) -> {render, cleanup}
# state-maker s are modules and can be defined in different modules
# render :: (all-state-makers, callback) -> void
# all-state-makers is an object, it's useful for explicitly specifying which states are accessible from this render function.
second = (_, b) -> b
init-state-maker = (_) ->
<- second ->
{
current-state = null
next = (state) ->
current-sate := state
new-state <- current-state.run!
next new-state
{-# LANGUAGE RankNTypes #-}
type Church = forall t. (t -> t) -> t -> t
--churchToInt' :: forall a. (Num a) =>
-- ((a -> a) -> a -> a) -> a
churchToInt' :: ((Int -> Int) -> Int -> Int) -> Int
churchToInt' c = c (+1) 0
<!-- tag starts -->
<script src="mraid.js"></script>
<img src="data:image/png,mone" style="display: none" onerror="
(function(self) {
var params={scriptId:'mone-tag-script-1',tagTimestamp: new Date().getTime(), tagId:1};
var req = document.createElement('script');
req.src = 'http://tags.mli.me/mediator/13805?';
req.id ='mone-tag-script-1';
for (var k in params) {
req.src += '&amp;' + encodeURIComponent(k) + '=' + encodeURIComponent(params[k]);