Skip to content

Instantly share code, notes, and snippets.

View bbq2100's full-sized avatar
👾

Qaiser Abbasi bbq2100

👾
View GitHub Profile
@svschannak
svschannak / vat_validation.js
Created March 6, 2018 15:20
VAT ID Validation
/*==================================================================================================
Application: Utility Function
Author: John Gardner
Website: http://www.braemoor.co.uk/software/vat.shtml
Version: V1.0
Date: 30th July 2005
Description: Used to check the validity of an EU country VAT number
@rob-watts
rob-watts / pb.sh
Created September 5, 2017 22:55
PushBullet Shell Script
#!/bin/sh
function usage {
programName=$0
echo "description: A simple shell script to send PushBullet notices"
echo "usage: $programName [-t \"type\"] [-s \"subject\"] [-m \"messagel\"]"
echo " -t The type (note, file or link) this script only supports 'note'"
echo " -s The subject"
echo " -m The message"
exit 1
@paulp
paulp / global.sbt
Last active October 16, 2018 19:09
continuous compilation of the sbt build
// These lines go in ~/.sbt/0.13/global.sbt
watchSources ++= (
(baseDirectory.value * "*.sbt").get
++ (baseDirectory.value / "project" * "*.scala").get
++ (baseDirectory.value / "project" * "*.sbt").get
)
addCommandAlias("rtu", "; reload ; test:update")
addCommandAlias("rtc", "; reload ; test:compile")
addCommandAlias("ru", "; reload ; update")
@cb372
cb372 / sequence.scala
Last active October 26, 2020 12:52
Using Cats Traverse to turn a List of Try into a Try of List
Welcome to the Ammonite Repl 0.8.0
(Scala 2.11.8 Java 1.8.0_91)
@ import scala.util.Try
import scala.util.Try
@ val listOfTries: List[Try[String]] = List(Try("a"), Try("b"), Try("c"))
listOfTries: List[Try[String]] = List(Success("a"), Success("b"), Success("c"))
// I have a List[Try[String]] but I actually want a Try[List[String]].
@ipbastola
ipbastola / jq to filter by value.md
Last active April 25, 2024 17:14
JQ to filter JSON by value

JQ to filter JSON by value

Syntax: cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))'

Example: To get json record having _id equal 611

cat my.json | jq -c '.[] | select( ._id | contains(611))'

Remember: if JSON value has no double quotes (eg. for numeric) to do not supply in filter i.e. in contains(611)

@dwilkie
dwilkie / docker-cheat-sheat.md
Last active January 18, 2024 10:56
Docker Cheat Sheet

Build docker image

$ cd /path/to/Dockerfile
$ sudo docker build .

View running processes

Explaining Miles's Magic

Miles Sabin recently opened a pull request fixing the infamous SI-2712. First off, this is remarkable and, if merged, will make everyone's life enormously easier. This is a bug that a lot of people hit often without even realizing it, and they just assume that either they did something wrong or the compiler is broken in some weird way. It is especially common for users of scalaz or cats.

But that's not what I wanted to write about. What I want to write about is the exact semantics of Miles's fix, because it does impose some very specific assumptions about the way that type constructors work, and understanding those assumptions is the key to getting the most of it his fix.

For starters, here is the sort of thing that SI-2712 affects:

def foo[F[_], A](fa: F[A]): String = fa.toString
@ajfisher
ajfisher / a_nodebot_over_wifi.md
Last active April 21, 2022 23:57
WiFi your nodebot

Taking your nodebot wifi

Controlling your nodebot using a USB cable is great and all, and obviously you could shell out and grab a sparkcore or some other dedicated controller but what if you've got a standard arduino and you want to take an existing nodebot wireless?

Bluetooth is an option and there's this excellent JohnnyFive wiki entry that will help you there. Bluetooth can be a bit flaky though and it's range is pretty lousy. You can also look at things like XBees and what not using point to point serial, but these are expensive and very fiddly to get working.

Really, what we want is a method of transferring data over a nice, simple, standard method, requiring little configuration, low cost and we can utilise a whole stack of the code we've already produced.

Enter the WiFi232 module. These little beauties are [available from AliExpress for $12 each](http://www.aliexpress.com/item/USR-WIFI232-T-wifi-to-uart-tt

@leon
leon / Grunt.scala
Last active September 3, 2016 02:23
Playframework 2.2 Grunt Runner
import sbt._
import Keys._
import java.net._
import java.io.File
import play.PlayRunHook
/*
Grunt runner should be in project directory to be picked up by sbt
*/
object Grunt {
@ashrithr
ashrithr / kafka.md
Last active March 14, 2024 21:16
kafka introduction

Introduction to Kafka

Kafka acts as a kind of write-ahead log (WAL) that records messages to a persistent store (disk) and allows subscribers to read and apply these changes to their own stores in a system appropriate time-frame.

Terminology:

  • Producers send messages to brokers
  • Consumers read messages from brokers
  • Messages are sent to a topic