Skip to content

Instantly share code, notes, and snippets.

View kelunik's full-sized avatar

Niklas Keller kelunik

View GitHub Profile
@NickCraver
NickCraver / BotLovin.cs
Last active January 5, 2023 11:36
Some bot/crawler fun on Stack Overflow. 10 hours of fun, to be precise.
private static readonly string[] tenHoursOfFun =
{
"https://www.youtube.com/watch?v=wbby9coDRCk",
"https://www.youtube.com/watch?v=nb2evY0kmpQ",
"https://www.youtube.com/watch?v=eh7lp9umG2I",
"https://www.youtube.com/watch?v=z9Uz1icjwrM",
"https://www.youtube.com/watch?v=Sagg08DrO5U",
"https://www.youtube.com/watch?v=5XmjJvJTyx0",
"https://www.youtube.com/watch?v=IkdmOVejUlI",
"https://www.youtube.com/watch?v=jScuYd3_xdQ",
@randomphrase
randomphrase / cmdoptions.cpp
Last active February 17, 2023 05:51
Demonstration of how to do subcommand option processing with boost program_options
#define BOOST_TEST_MODULE subcommand options
#include <boost/test/unit_test.hpp>
#include <boost/program_options.hpp>
#include <boost/variant/variant.hpp>
#include <boost/variant/get.hpp>
struct GenericOptions {
bool debug_;
};
@hikari-no-yume
hikari-no-yume / example.php
Created March 20, 2017 20:02
function chaining for PHP 7
<?php declare(strict_types=1);
require_once "✨.🐘";
✨($_)->strlen("foo")->var_dump($_);
@halfnibble
halfnibble / HashFunction.ts
Last active October 13, 2023 11:35
Hash function to debug absolute paths sent to the update chunk hash method in webpack.
import * as crypto from 'crypto';
import * as fs from 'fs';
import * as path from 'path';
/**
* Interface for Webpack's hashFunction
*/
export interface IHashFunction {
update: (data: string | Buffer, encoding: string) => IHashFunction;
digest: (encoding: string) => string | Buffer;
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@liamnewmarch
liamnewmarch / format-relative.js
Last active November 3, 2023 15:29
Relative time strings using the web platform
/**
* The target language. [Browser support is good][1] but "en-US" is a safe default.
*
* [1]: https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/language
*
* @type {string}
*/
const { language = "en-US" } = navigator;
/**
@xkr47
xkr47 / log4j.properties
Created August 29, 2013 19:02
log4j configuration with different colors for different log levels - also works with Eclipse Ansi Console: http://mihai-nita.net/2013/06/03/eclipse-plugin-ansi-in-console/
log4j.debug=false
# Default level is INFO
log4j.rootLogger=INFO,StdoutErrorFatal,StdoutWarn,StdoutInfo,StdoutDebug,StdoutTrace
# and for com.some.package.* log everything
log4j.logger.com.some.package=TRACE
log4j.appender.StdoutErrorFatal=org.apache.log4j.ConsoleAppender
log4j.appender.StdoutErrorFatal.layout=org.apache.log4j.PatternLayout
@Thinkscape
Thinkscape / flattenExceptionBacktrace.php
Last active December 28, 2023 12:28
Make any PHP Exception serializable by flattening complex values in backtrace.
<?php
function flattenExceptionBacktrace(\Exception $exception) {
$traceProperty = (new \ReflectionClass('Exception'))->getProperty('trace');
$traceProperty->setAccessible(true);
$flatten = function(&$value, $key) {
if ($value instanceof \Closure) {
$closureReflection = new \ReflectionFunction($value);
$value = sprintf(
'(Closure at %s:%s)',
@rauchg
rauchg / README.md
Last active January 6, 2024 07:19
require-from-twitter
@magicznyleszek
magicznyleszek / jekyll-and-liquid.md
Last active January 12, 2024 03:46
Jekyll & Liquid Cheatsheet

Jekyll & Liquid Cheatsheet

A list of the most common functionalities in Jekyll (Liquid). You can use Jekyll with GitHub Pages, just make sure you are using the proper version.

Running

Running a local server for testing purposes: