Skip to content

Instantly share code, notes, and snippets.

View filippovitale's full-sized avatar

Filippo Vitale filippovitale

View GitHub Profile
import scalaz._
import scala.util.Try
final class X {
val magic: Int = scala.util.Random.nextInt(10000)
def isStable: Boolean = magic == 42
}
object Main extends App {
@gak
gak / gist:8537275
Created January 21, 2014 09:51
dude
void main(void)
{
float x,y;
float ratio = iResolution.y / iResolution.x;
x = gl_FragCoord.x / iResolution.x - 0.5;
y = gl_FragCoord.y / iResolution.y * ratio - 0.25;
float PI = 3.14159265358979323846264;
@arosien
arosien / runar-io-free.scala
Last active September 10, 2016 07:17
Translation of Runar's ScalaIO 2013 presentation on IO and Free monads (http://blog.higher-order.com/assets/scalaio.pdf) to scalaz.
import scalaz._
import Scalaz._
import Free._
/** "Pure" interactions with a console. */
sealed trait Console[+A]
case class GetLine[A](k: String => A) extends Console[A]
case class PutLine[A](s: String, a: A) extends Console[A]
object Console {
/**
* Original source:
* [[https://gist.github.com/oxbowlakes/970717]]
*
* Modifications:
* - use scala 7.0.5
* - use toValidationNel
* - use sequenceU and traverseU instead of the lambda trick
*
* Part Zero : 10:15 Saturday Night

Advanced Functional Programming with Scala - Notes

Copyright © 2017 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@oxbowlakes
oxbowlakes / 3nightclubs.scala
Created May 13, 2011 15:14
A Tale of 3 Nightclubs
/**
* Part Zero : 10:15 Saturday Night
*
* (In which we will see how to let the type system help you handle failure)...
*
* First let's define a domain. (All the following requires scala 2.9.x and scalaz 6.0)
*/
import scalaz._
import Scalaz._
@ryanmark
ryanmark / responsive-screens.js
Created March 5, 2012 15:59
Easy responsive screenshots with Phantom.js
/*
* Take a set of full height screenshots for a range of screensizes.
* phantomjs responsive-screens.js http://www.cnn.com/ png
*
* This will create a directory tree in your current directory which
* mirrors the URL. All files will be named with the current time.
* You can run this on a cron to build an archive of screenshots.
**/
var page = new WebPage(),
import scala.io.StdIn.readLine
import scala.util.Try
/**
* Trivial code, anyone would understand what's going on here.
* But requirements change, and we never know in which direction the change will be.
*
* The code has a procedural and interactive nature, how would you go about this in another, let alone better way?
* Still, it has bugs; so let's find them and solve them first
*/
@derpston
derpston / cursestest.py
Created April 11, 2012 17:56
Python curses example
# Scatters dots randomly on your terminal as a quick demo of curses.
import curses
import random
import time
window = curses.initscr()
try:
(h, w) = window.getmaxyx()
@manuel-rabade
manuel-rabade / huawei_e303_api_device
Last active October 26, 2020 10:19
API del modem Huawei E303
$ curl http://192.168.1.1/api/device/information
<?xml version="1.0" encoding="UTF-8"?>
<response>
<DeviceName>E303</DeviceName>
<SerialNumber>K3XBYAxxxxxxxxxx</SerialNumber>
<Imei>xxxxxxxxxxxxxxx</Imei>
<Imsi>xxxxxxxxxxxxxxx</Imsi>
<Iccid>xxxxxxxxxxxxxxxxxxxx</Iccid>
<Msisdn></Msisdn>
<HardwareVersion>CH2E303SM</HardwareVersion>