Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@premek
premek / mv.sh
Last active March 5, 2024 17:43
Rename files in linux / bash using mv command without typing the full name two times
# Put this function to your .bashrc file.
# Usage: mv oldfilename
# If you call mv without the second parameter it will prompt you to edit the filename on command line.
# Original mv is called when it's called with more than one argument.
# It's useful when you want to change just a few letters in a long name.
#
# Also see:
# - imv from renameutils
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste)
@munificent
munificent / generate.c
Last active March 18, 2024 08:31
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u

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

anonymous
anonymous / response.md
Created October 6, 2016 14:29
Response to recent InfoQ article

Most of what's written in this article is deliberately biased and wrong. It is yet another in the stream of Scala-hating posts that people. I analyze the article below:

  1. TIOBE index is a metric based on search engine ranking policies and can be intentionally or unintentionally gamed.

    https://blog.timbunce.org/2009/05/17/tiobe-index-is-being-gamed/

On these rankings, Scala is quite high:

@ethack
ethack / TypeClipboard.md
Last active April 16, 2024 09:14
Scripts that simulate typing the clipboard contents. Useful when pasting is not allowed.

It "types" the contents of the clipboard.

Why can't you just paste the contents you ask? Sometimes pasting just doesn't work.

  • One example is in system password fields on OSX.
  • Sometimes you're working in a VM and the clipboard isn't shared.
  • Other times you're working via Remote Desktop and again, the clipboard doesn't work in password boxes such as the system login prompts.
  • Connected via RDP and clipboard sharing is disabled and so is mounting of local drives. If the system doesn't have internet access there's no easy way to get things like payloads or Powershell scripts onto it... until now.

Windows

The Windows version is written in AutoHotKey and easily compiles to an executable. It's a single line script that maps Ctrl-Shift-V to type the clipboard.

@pathikrit
pathikrit / SudokuSolver.scala
Last active April 12, 2024 15:00
Sudoku Solver in Scala
val n = 9
val s = Math.sqrt(n).toInt
type Board = IndexedSeq[IndexedSeq[Int]]
def solve(board: Board, cell: Int = 0): Option[Board] = (cell%n, cell/n) match {
case (r, `n`) => Some(board)
case (r, c) if board(r)(c) > 0 => solve(board, cell + 1)
case (r, c) =>
def guess(x: Int) = solve(board.updated(r, board(r).updated(c, x)), cell + 1)
val used = board.indices.flatMap(i => Seq(board(r)(i), board(i)(c), board(s*(r/s) + i/s)(s*(c/s) + i%s)))
anonymous
anonymous / untrusted-lvl20-solution.js
Created May 4, 2014 20:38
Solution to level 20 in Untrusted: http://alex.nisnevich.com/untrusted/
/*****************
* bossFight.js *
*****************
*
* NO FARTHER, DR. EVAL!!!!
* YOU WILL NOT GET OUT OF HERE ALIVE!!!!
* IT'S TIME YOU SEE MY TRUE FORM!!!!
* FACE MY ROBOT WRATH!!!!!
*/
anonymous
anonymous / untrusted-lvl16-solution.js
Created May 1, 2014 22:26
Solution to level 16 in Untrusted: http://alex.nisnevich.com/untrusted/
/*************
* lasers.js *
*************
*
* Time to unleash the killer lasers! Each laser will kill you
* unless you have the appropriate color. Too bad you can't
* see which color corresponds to which laser!
*/
function getRandomInt(min, max) {
anonymous
anonymous / untrusted-lvl15-solution.js
Created May 1, 2014 22:20
Solution to level 15 in Untrusted: http://alex.nisnevich.com/untrusted/
/**************************
* exceptionalCrossing.js *
**************************
*
* Sorry, old friend, but I'm afraid I can't share
* co-authorship on this paper. You've done a very
* good job getting this Algorithm for me. The bit
* with the keys was especially clever! I wouldn't
* have thought of it myself. But then, of course,
* that's why you were here in the first place.
anonymous
anonymous / untrusted-lvl14-solution.js
Created May 1, 2014 22:16
Solution to level 14 in Untrusted: http://alex.nisnevich.com/untrusted/
/********************
* crispsContest.js *
********************
*
* The Algorithm is almost in our grasp!
* At long last, we will definitively establish
* that 3SAT is solvable in polynomial time. It's
* been a long, strange journey, but it will all be
* worth it.
*