Skip to content

Instantly share code, notes, and snippets.

@joepie91
joepie91 / express-server-side-rendering.md
Last active February 20, 2024 20:52
Rendering pages server-side with Express (and Pug)

Terminology

  • View: Also called a "template", a file that contains markup (like HTML) and optionally additional instructions on how to generate snippets of HTML, such as text interpolation, loops, conditionals, includes, and so on.
  • View engine: Also called a "template library" or "templater", ie. a library that implements view functionality, and potentially also a custom language for specifying it (like Pug does).
  • HTML templater: A template library that's designed specifically for generating HTML. It understands document structure and thus can provide useful advanced tools like mixins, as well as more secure output escaping (since it can determine the right escaping approach from the context in which a value is used), but it also means that the templater is not useful for anything other than HTML.
  • String-based templater: A template library that implements templating logic, but that has no understanding of the content it is generating - it simply concatenates together strings, potenti
@subfuzion
subfuzion / curl.md
Last active April 26, 2024 09:43
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@balzer82
balzer82 / TimeSeries-Decomposition.ipynb
Last active June 20, 2022 14:38
TimeSeries Decomposition in Python with statsmodels and Pandas
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pirafrank
pirafrank / uninstall_office_2016.sh
Last active March 21, 2024 14:12
Uninstall Office 2016 from OS X completely
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo -e "
ROOT PRIVILEDGES NEEDED!
You have to run this script as root.
Aborting...
"
exit 1
else
@nebw
nebw / arXiv popularity scoring.ipynb
Created September 6, 2015 12:07
Popularity scoring for arXiv publications
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@CamDavidsonPilon
CamDavidsonPilon / 538.json
Last active November 28, 2021 07:37
Use the two files below to mimic graphs on 538. www.dataorigami.net/blogs/fivethirtyeight-mpl
{
"lines.linewidth": 2.0,
"examples.download": true,
"patch.linewidth": 0.5,
"legend.fancybox": true,
"axes.color_cycle": [
"#30a2da",
"#fc4f30",
"#e5ae38",
"#6d904f",
@robschmuecker
robschmuecker / README.md
Last active April 24, 2024 14:12
D3.js Drag and Drop, Zoomable, Panning, Collapsible Tree with auto-sizing.

This example pulls together various examples of work with trees in D3.js.

The panning functionality can certainly be improved in my opinion and I would be thrilled to see better solutions contributed.

One can do all manner of housekeeping or server related calls on the drop event to manage a remote tree dataset for example.

Dragging can be performed on any node other than root (flare). Dropping can be done on any node.

Panning can either be done by dragging an empty part of the SVG around or dragging a node towards an edge.

@panisson
panisson / ncp.py
Last active June 9, 2020 01:44
Nonnegative Tensor Factorization, based on the Matlab source code available at Jingu Kim's home page: https://sites.google.com/site/jingukim/home#ntfcode Requires the installation of Numpy and Scikit-Tensor (https://github.com/mnick/scikit-tensor). For examples, see main() function.
# Copyright (C) 2013 Istituto per l'Interscambio Scientifico I.S.I.
# You can contact us by email (isi@isi.it) or write to:
# ISI Foundation, Via Alassio 11/c, 10126 Torino, Italy.
#
# This work is licensed under a Creative Commons 4.0
# Attribution-NonCommercial-ShareAlike License
# You may obtain a copy of the License at
# http://creativecommons.org/licenses/by-nc-sa/4.0/
#
# This program was written by Andre Panisson <panisson@gmail.com> at
@cjbayesian
cjbayesian / bayes_update.R
Created August 16, 2012 20:23
generate a video demonstrating Bayesian updating
## Corey Chivers, 2012 ##
sim_bayes<-function(p=0.5,N=100,y_lim=20,a_a=2,a_b=10,b_a=8,b_b=3)
{
## Simulate outcomes in advance
outcomes<-sample(1:0,N,prob=c(p,1-p),replace=TRUE)
success<-cumsum(outcomes)
for(frame in 1:N)
{
png(paste("plots/",1000+frame,".png",sep=""))
@catawbasam
catawbasam / pandas_dbms.py
Last active February 17, 2024 15:16
Python PANDAS : load and save Dataframes to sqlite, MySQL, Oracle, Postgres
# -*- coding: utf-8 -*-
"""
LICENSE: BSD (same as pandas)
example use of pandas with oracle mysql postgresql sqlite
- updated 9/18/2012 with better column name handling; couple of bug fixes.
- used ~20 times for various ETL jobs. Mostly MySQL, but some Oracle.
to do:
save/restore index (how to check table existence? just do select count(*)?),
finish odbc,