Skip to content

Instantly share code, notes, and snippets.

@hayleyxyz
hayleyxyz / AsciiSafeDownloadFile.php
Created November 4, 2014 21:04
Laravel workaround for Symphony Download Response Error: "the filename fallback must only contain ASCII characters". Extend the Symfony\Component\HttpFoundation\File\File object to return an ASCII-safe value for getFilename()
<?php
use Symfony\Component\HttpFoundation\File\File;
/*
This class is a hack/workaround for the InvalidArgumentException "The filename fallback must only contain ASCII characters."
for file downloads with non-ASCII filenames. Since the Response::download() method doesn't allow specifying a fallback name,
this is the only realistic option, aside from extending, rewriting, and maintaining a bunch of framework classes, or
modifying the framework itself.
*/
{
"id": 617991,
"token": "6c3afbfe52",
"title": "(C80) [Fukunoren (Yukiwo)] labyrinth (Alice In Wonderland) [SMDC] [English]",
"title_jp": "(C80) [福のれん (ユキヲ)] labyrinth (ふしぎの国のアリス) [英訳]",
"uploader": "shuntensatsu",
"rating_count": 96,
"rating_average": 4.72,
"images_count": 19,
"file_size": 16714949,
@hayleyxyz
hayleyxyz / server.js
Created January 26, 2015 19:59
node.js http server
var http = require('http');
if(process.argv.length < 3) {
console.error('Missing listen address argument');
return;
}
var listenAddress = process.argv[2];
var server = http.createServer(function (req, res) {
$ bash -c "echo '2 eth1_rt' >> /etc/iproute2/rt_tables"
$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto eth0
iface eth0 inet dhcp
auto eth0:1
#!/usr/bin/env php
<?php
/*
* This script will transform file names for templates downloaded for OpenVZ[1],
* to match the format used in Proxmox[2].
*
* [1] https://download.openvz.org/template/precreated/
* [2] http://pve.proxmox.com/wiki/Template_naming_convention
*
@hayleyxyz
hayleyxyz / interfaces
Created December 13, 2015 05:31
Proxmox NAT - /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# vmbr0: Bridging. Make sure to use only MAC adresses that were assigned to you.
auto vmbr0
iface vmbr0 inet static
@hayleyxyz
hayleyxyz / adb.sh
Created December 16, 2015 03:56
adb logcat example
# Usage: logcat [options] [filterspecs]
# (adb logcat or run logcat from shell inside Android)
# filterspecs are a series of
# <tag>[:priority]
#
# where <tag> is a log component tag (or * for all) and priority is:
# V Verbose
# D Debug
# I Info
# W Warn
embed: function(t, e) {
var i = function(t) {
var e = JSON.parse(t.data),
i = e.action,
n = e.data || {};
void 0 !== mediamanager[i] && mediamanager[i](n)
};
this.eventsSet || (void 0 !== window.addEventListener ? (window.removeEventListener("message", i), window.addEventListener("message", i)) : (window.detachEvent("onmessage", i), window.attachEvent("onmessage", i)), this.eventsSet = !0), void 0 === this.meta.pageurl && (this.meta.pageurl = window.location.href), void 0 === this.autoresize && (this.autoresize = !1), void 0 === this.aspect && (this.aspect = ["16", "6"]);
var n,
r = void 0 !== this.scroll && this.scroll;
#include <iostream>
#include <SDL.h>
void draw(SDL_Window * window, SDL_Renderer * renderer) {
int w, h;
SDL_GetWindowSize(window, &w, &h);
for (int y = 0; y < h; ++y) {
for (int x = 0; x < w; ++x) {
//srand(x * y);
@hayleyxyz
hayleyxyz / install_realpath.sh
Created June 7, 2019 23:13
Install realpath on macOS using GNU coreutils
#!/bin/sh
curl https://ftp.gnu.org/gnu/coreutils/coreutils-8.31.tar.xz -O
tar xf coreutils-8.31.tar.xz
cd coreutils-8.31
./configure --enable-no-install-program=$(./build-aux/gen-lists-of-programs.sh --list-progs | tr '\n' ',' | sed -e 's/realpath,//' -e 's/,$//')
make
ln -s $(which install) src/ginstall # Hack because we didn't build GNU install, but make install requires it
echo "\nNow run 'make install' to install realpath\n"