Skip to content

Instantly share code, notes, and snippets.

View gekomad's full-sized avatar

Giuseppe Cannella gekomad

View GitHub Profile
@N0rbert
N0rbert / meld
Last active October 26, 2020 22:24
Caja-Actions script to compare files or directories by using Meld in Caja, should be placed to `~/.config/caja/scripts`, was found sometime ago on the Deutsch forum
#!/bin/bash
#
# meld script for caja, place it to ~/.config/caja/scripts
#
# Copyright 2014 Norbert ..... <norbert@Entwicklung>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
@Dani4kor
Dani4kor / Python FEN chess Validation with regular expression
Last active August 24, 2024 22:10
Python FEN chess Validation with regular expression
def fenPass(fen):
"""
"""
regexMatch=re.match('\s*^(((?:[rnbqkpRNBQKP1-8]+\/){7})[rnbqkpRNBQKP1-8]+)\s([b|w])\s([K|Q|k|q]{1,4})\s(-|[a-h][1-8])\s(\d+\s\d+)$', fen)
if regexMatch:
regexList = regexMatch.groups()
fen = regexList[0].split("/")
if len(fen) != 8:
raise ValueError("expected 8 rows in position part of fen: {0}".format(repr(fen)))
case class Node(value: Int,
left: Option[Node] = None,
right: Option[Node] = None)
object Serializer {
private val pattern = """^(\d+)\((.*)\)$""".r
private val treeOpen = '('
private val treeClose = ')'
private val separator = ','
private val separatorLength = 1
@carymrobbins
carymrobbins / pretty-print.scala
Last active January 17, 2024 14:02
Pretty print Scala case classes and other data structures.
/**
* Pretty prints a Scala value similar to its source represention.
* Particularly useful for case classes.
* @param a - The value to pretty print.
* @param indentSize - Number of spaces for each indent.
* @param maxElementWidth - Largest element size before wrapping.
* @param depth - Initial depth to pretty print indents.
* @return
*/
private def prettyPrint(a: Any, indentSize: Int = 2, maxElementWidth: Int = 30, depth: Int = 0): String = {
@stefansundin
stefansundin / extract-attachments.py
Last active September 27, 2022 18:54
Extract attachments from emails that Gmail doesn't allow you to download. This is dumb. Please use Python >= 3.4.
#!/usr/bin/env python3
# Get your files that Gmail block. Warning message:
# "Anti-virus warning - 1 attachment contains a virus or blocked file. Downloading this attachment is disabled."
# Based on: https://spapas.github.io/2014/10/23/retrieve-gmail-blocked-attachments/
# Instructions:
# Go to your emails, click the arrow button in the top right, "Show original", then "Download Original".
# Move the files to the same directory as this program, then run it.
import sys
@niksumeiko
niksumeiko / git.migrate
Last active August 27, 2024 08:20
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@jeroenr
jeroenr / JsonUtil.scala
Last active September 12, 2018 08:28
Easy JSON (un)marshalling in Scala with Jackson
import com.fasterxml.jackson.databind.{DeserializationFeature, ObjectMapper}
import com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
object JsonUtil {
val mapper = new ObjectMapper with ScalaObjectMapper
mapper.registerModule(DefaultScalaModule)
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
def toJson(value: Map[Symbol, Any]): String = {
package forcomp
import common._
object Anagrams {
/** A word is simply a `String`. */
type Word = String
/** A sentence is a `List` of words. */
@mariussoutier
mariussoutier / Mail.scala
Created August 23, 2012 12:13
Sending mails fluently in Scala
package object mail {
implicit def stringToSeq(single: String): Seq[String] = Seq(single)
implicit def liftToOption[T](t: T): Option[T] = Some(t)
sealed abstract class MailType
case object Plain extends MailType
case object Rich extends MailType
case object MultiPart extends MailType
@endolith
endolith / readme.md
Last active August 30, 2024 17:32
How to stream a webcam to a web browser in Ubuntu

Grr this took hours to figure out. I was trying to install MJPG-streamer and running VLC command lines and all this crap but nothing worked.

First install motion:

~> sudo apt-get install motion

Then create a config file:

~> mkdir ~/.motion

~> nano ~/.motion/motion.conf