Skip to content

Instantly share code, notes, and snippets.

View hrj's full-sized avatar
🔭
observing

hrj hrj

🔭
observing
View GitHub Profile
@bobmurdoch
bobmurdoch / tailwind_color_variables.scss
Created October 8, 2018 20:26
Tailwind CSS colors as Sass variables
$black: #22292f;
$grey-darkest: #3d4852;
$grey-darker: #606f7b;
$grey-dark: #8795a1;
$grey: #b8c2cc;
$grey-light: #dae1e7;
$grey-lighter: #f1f5f8;
$grey-lightest: #f8fafc;
$white: #fff;
$red-darkest : #3b0d0c;
@vassjozsef
vassjozsef / webrtc.md
Last active March 4, 2019 04:34
WebRTC-65 for Java 7 Applications

Discord app targets API level 16, which does not support Java 8. Fortunately, with desugaring, we can still support API level 16, please see https://developer.android.com/studio/write/java8-support.html - however, external libraries already need to be desugared.

Java 8 is needed for building WebRTC 65. Instead of a single libwebrtc.jar, the following files are generated (javap -verbose MyClass | grep "major"):

Name Version Notes
libwebrtc.jar 52 ThreadUtils and Logging classes
audio_device_java.interface.java 52
audio_device_java.jar 51
libjingle_peerconnection_java.interface.jar 52
@ErikAugust
ErikAugust / spectre.c
Last active July 5, 2024 18:14
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@bogas04
bogas04 / server.js
Created October 3, 2015 16:33
NodeJS Server with deflated response
// NOTE: Relies on ES6 syntax, works on Node 4.0.0 or higher
var zlib = require('zlib');
require('http')
.createServer((req, res) => {
res.writeHead(200, {
'Content-encoding': 'deflate',
'Content-length': zlib.deflateSync(body).length
});
res.write(zlib.deflateSync(body));
@paulirish
paulirish / what-forces-layout.md
Last active July 5, 2024 08:26
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@hrj
hrj / alias.md
Last active November 29, 2023 09:50
pwd alias hell

TL;DR

When you are in a shell in Linux, you may be led to believe you are in directory xyz but might actually be in directory pqr.


Demonstration

In a terminal,

@maiatoday
maiatoday / getdb
Last active December 7, 2015 10:10
getdb - little shell script to pull the db for an app on an android emulator or device.
#!/bin/bash
display_usage() {
echo -e "\nUsage:\n`basename $0` -p [package] -n [dbname] \n"
}
# if less than two arguments supplied, display usage
if [ $# -le 2 ]
then
display_usage
@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)))
@viktorklang
viktorklang / minscalaactors.scala
Last active March 25, 2024 19:01
Minimalist Scala Actors
/*
Copyright 2012-2021 Viktor Klang
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@timaschew
timaschew / InteractiveGnuPlot.java
Created July 12, 2011 17:30
Using library JavaPlot for interactive rotating a Gnuplot in a JPanel
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import javax.swing.JFrame;
import com.panayotis.gnuplot.JavaPlot;
import com.panayotis.gnuplot.swing.JPlot;
// include JavaPlot.jar from this site to your classpath
// http://gnujavaplot.sourceforge.net/JavaPlot/About.html