Skip to content

Instantly share code, notes, and snippets.

@kevinmeredith
kevinmeredith / gist:1e899f38717be37c321e
Last active August 29, 2015 14:21
Implementation of a Simple State Machine in Scala/Akka

Implementing a Simple State Machine with Akka

Problem

Prof. Charles Pinter's A Book of Abstract Algebra presents the following exercise:

Ch 6 (Functions) part H, problem 4
Given a stream of 1's and 0's, draw the state machine diagram if the stream ends with 111

I came up with the following diagram:

@LukaHorvat
LukaHorvat / SliderPuzzle.hs
Created October 5, 2015 23:15
SliderPuzzle.hs
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module SliderPuzzle where
import Prelude hiding (Either(..))
import Data.Vector (Vector, (//), (!?))
import qualified Data.Vector as Vec
import Control.Arrow (second, (***))
import Control.Monad.State.Strict
import Data.Set (Set)
import qualified Data.Set as Set
@jdennes
jdennes / CreateSendOAuthTest.java
Last active December 14, 2015 00:09
A Java application to demonstrate authenticating with the Campaign Monitor API using OAuth. Uses the createsend-java library as well as the Spark micro web framework (but could easily be adapted for use with any Java web application framework).
// Ensure you set the CREATESEND_CLIENT_ID, CREATESEND_CLIENT_SECRET,
// and CREATESEND_REDIRECT_URI environment variables for your registered
// OAuth application.
import static spark.Spark.*;
import spark.*;
import com.createsend.General;
import com.createsend.models.clients.ClientBasics;
import com.createsend.models.OAuthTokenDetails;
import com.createsend.util.AuthenticationDetails;
defmodule Benchmark do
def measure(function) do
elapsed = function
|> :timer.tc
|> elem(0)
|> Kernel./(1_000_000)
IO.puts "Elapsed = #{elapsed}s"
end
end
@iszlai
iszlai / himawari.ps1
Created February 4, 2016 11:24 — forked from MichaelPote/himawari.ps1
Windows Powershell Script to download the latest image from the Himawari-8 satelite, combine the tiles into a single image, convert to jpg and then set as the desktop background.
#
# Himawari-8 Downloader
#
#
#
# This script will scrape the latest image from the Himawari-8 satellite, recombining the tiled image,
# converting it to a JPG which is saved in My Pictures\Himawari\ and then set as the desktop background.
#
# http://himawari8.nict.go.jp/himawari8-image.htm
#
@pathikrit
pathikrit / GitPunchCard.scala
Last active April 15, 2018 11:17
Scala Script to print Git PunchCard
/**
* Quick and dirty Scala app to print git commit punch-card e.g.
*
* ┃08┃09┃10┃11┃12┃13┃14┃15┃16┃17┃18┃19┃20┃21┃22┃23┃00┃01┃02┃03┃04┃05┃06┃07┃
* Sun┃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
* Mon┃▁▁▁▄▄▄▅▅▅▅▅▅▄▄▄▆▆▆▇▇▇▇▇▇███▆▆▆▅▅▅▄▄▄▃▃▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
* Tue┃▁▁▁▃▃▃▆▆▆▅▅▅▅▅▅▅▅▅▆▆▆▇▇▇▆▆▆▆▆▆▅▅▅▅▅▅▄▄▄▃▃▃▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
* Wed┃▁▁▁▄▄▄▅▅▅▇▇▇▅▅▅▅▅▅███▇▇▇▅▅▅▆▆▆▇▇▇▃▃▃▃▃▃▂▂▂▂▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
* Thu┃▁▁▁▂▂▂▄▄▄▆▆▆▅▅▅▆▆▆▇▇▇▇▇▇▆▆▆▇▇▇▅▅▅▄▄▄▃▃▃▂▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
* Fri┃▁▁▁▂▂▂▄▄▄▅▅▅▅▅▅▄▄▄▄▄▄▅▅▅▅▅▅▃▃▃▃▃▃▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

Getting Started in Scala

This is my attempt to give Scala newcomers a quick-and-easy rundown to the prerequisite steps they need to a) try Scala, and b) get a standard project up and running on their machine. I'm not going to talk about the language at all; there are plenty of better resources a google search away. This is just focused on the prerequisite tooling and machine setup. I will not be assuming you have any background in JVM languages. So if you're coming from Python, Ruby, JavaScript, Haskell, or anywhere…  I hope to present the information you need without assuming anything.

Disclaimer It has been over a decade since I was new to Scala, and when I was new to Scala, I was coming from a Java and Ruby background. This has probably caused me to unknowingly make some assumptions. Please feel free to call me out in comments/tweets!

One assumption I'm knowingly making is that you're on a Unix-like platform. Sorry, Windows users.

Getting the JVM

@pbssubhash
pbssubhash / Google XSS challenge solutions..
Last active August 2, 2023 03:38
Solutions of the Google XSS Challenge..
Hey All,
I am P.B.Surya.Subhash, a 17 Year coder,hacker and a student.
Recently I happen to see so many posts regarding this " Google XSS Challenge " and i was fortunate enough to complete them..
These are the solutions for the challenges ;)
##############################################################################
Level 1: Hello, world of XSS
https://xss-game.appspot.com/level1/frame
query=<script>alert('xss')</script>
@non
non / answer.md
Last active January 9, 2024 22:06
answer @nuttycom

What is the appeal of dynamically-typed languages?

Kris Nuttycombe asks:

I genuinely wish I understood the appeal of unityped languages better. Can someone who really knows both well-typed and unityped explain?

I think the terms well-typed and unityped are a bit of question-begging here (you might as well say good-typed versus bad-typed), so instead I will say statically-typed and dynamically-typed.

I'm going to approach this article using Scala to stand-in for static typing and Python for dynamic typing. I feel like I am credibly proficient both languages: I don't currently write a lot of Python, but I still have affection for the language, and have probably written hundreds of thousands of lines of Python code over the years.

@ddevault
ddevault / Makefile
Last active February 20, 2024 14:17
Tiny Wayland compositor
WAYLAND_PROTOCOLS=/usr/share/wayland-protocols
# wayland-scanner is a tool which generates C headers and rigging for Wayland
# protocols, which are specified in XML. wlroots requires you to rig these up
# to your build system yourself and provide them in the include path.
xdg-shell-protocol.h:
wayland-scanner server-header \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
xdg-shell-protocol.c: xdg-shell-protocol.h