Skip to content

Instantly share code, notes, and snippets.

@fitsum
fitsum / stream-pdf-from-nodejs.js
Created January 25, 2024 10:42 — forked from InsilicoSoft/stream-pdf-from-nodejs.js
Stream local pdf file from nodejs (restify) server to client
server.get('/downloadPdf/:fileData', function (req, res) {
// config
var fileData = Buffer.from(req.params.fileData, 'base64');
var menuData = JSON.parse(fileData.toString());
var userName = menuData.userName;
var menuName = slug(menuData.menuName);
var fileName = userName + "-" + menuName + PDF_EXT;
var filePath = PDF_PATH + fileName;
// process headers
<?php
# Parameters:
# name: The name field the user supplied, minus any tripcode (before #)
# email: User supplied email field
# sub: user supplied subject field
# com: user supplied comment field (before or after wordfilters? dunno)
# md5: md5 of the supplied image. null if no image.
# ip: the IP of the user, in unsigned integer (packed) form
# mod: true if the user is a mod
#
@fitsum
fitsum / scratchmarklet.js
Created November 22, 2020 04:15
bookmarklet version of scratch.js
data:text/html, <html lang="en"><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>*scratch*</title><style> body{font-family:Hack,Menlo,Monaco,'Droid Sans Mono','Courier New',monospace;white-space:pre}body style{display:inline}style::before{content:'<style>'}style::after{content:'<\/style>'}*::before,*::after{color:rgba(136,18,128,0.5)}</style><script> const selectOuterMostNonBodyNode = (node) => node.parentNode.tagName === 'BODY' ? node : node.parentNode;function insertAfterSelection(selection,html){if(html === '') return;let nodeToInsert=document.createElement('div');nodeToInsert.innerHTML=html + '<br>';let range=selection.getRangeAt(0);let clone=range.cloneRange();let {endContainer} = range;range.setStartAfter(selectOuterMostNonBodyNode(endContainer)); range.insertNode(nodeToInsert);clone.setStart(clone.endContainer, clone.endOffset);selection.removeRange(range); selection.addRange(clone);} var globalEval=eval;function evaluate(){let selection=documen
@nauhygon
nauhygon / Build Emacs for Windows 64bit with Native Compilation.md
Last active April 26, 2024 05:17
Step-by-step instructions to build Emacs for Windows 64 bit with MSYS2 and MinGW-w64. Now `native-comp` supported.

Build Emacs-w64 with MSYS2/MinGW-w64 with Native Compilation

Instructions are modified from emacs-w64 Wiki page by zklhp. Many thanks for sharing!

  1. Download the latest MSYS2 from this download page.

  2. Install MSYS2 to, for example, C:\msys2 (make sure no space in path to avoid unwanted problems).

  3. Optionally prettify the MSYS2 console mintty with ~/.minttyrc to make it more pleasing to eyes. Thanks to this awesome theme!

@fitsum
fitsum / _grid-base.sass
Created January 20, 2012 20:52
Fluid Desktop & Mobile Grid
// This file requires Sass & Compass.
//
// - http://sass-lang.com
// - http://compass-style.org
// For box-sizing.
@import compass/css3
// `Clear floated elements.
//----------------------------------------------------------------------------------------------------
@fitsum
fitsum / grep_dir
Created July 9, 2013 20:52
recursive directory search for file with line containing "mail("
egrep -ir --include=*.{php,html,js} "mail\(" .
<script type="text/javascript">
$(document).ready(function(){
$('a').on('click',function(){
var $href = $(this).attr('href');
var $pptDoc = new RegExp(".ppt$").test($href);
var $wordDoc = new RegExp(".doc$").test($href);
var $pdfDoc = new RegExp(".pdf$").test($href);
var $docType;
function push2GA(thisURL,thisOptValue){
_gaq.push(['_trackEvent', 'Download', thisURL, thisOptValue]);
@fitsum
fitsum / PHP menu maker
Created June 12, 2014 15:33
Lists files & directories recursively
// lists files & directories recursively
<?
function menu($dir){
$files = glob($dir.'/*');
$html = '<ul>';
foreach($files as $file){
if(is_dir($file)){
// FB 6/12
// added bc it wasn't tharr
@fitsum
fitsum / cmd.php
Last active April 26, 2024 05:12
executes on shell commands via browser + TODOs
<!DOCTYPE html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>CMD</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
/* Eric Meyer's Reset CSS v2.0 - http://cssreset.com */
@fitsum
fitsum / html5_mvp.sublime-snippet
Last active April 26, 2024 05:12
sublime snippet for mvp
<snippet>
<content><![CDATA[<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">