Skip to content

Instantly share code, notes, and snippets.

View sniperwolf's full-sized avatar

Fabrizio Fallico sniperwolf

View GitHub Profile
@ziadoz
ziadoz / index.php
Last active June 2, 2023 23:08
Simple PHP / jQuery CSRF Protection
<?php
// See: http://blog.ircmaxell.com/2013/02/preventing-csrf-attacks.html
// Start a session (which should use cookies over HTTP only).
session_start();
// Create a new CSRF token.
if (! isset($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = base64_encode(openssl_random_pseudo_bytes(32));
}
@necolas
necolas / README.md
Last active March 28, 2024 20:34
Experimenting with component-based HTML/CSS naming and patterns

NOTE I now use the conventions detailed in the SUIT framework

Template Components

Used to provide structural templates.

Pattern

t-template-name
@kimmel
kimmel / .perltidyrc
Created October 22, 2011 12:29
.perltidyrc Perl Best Practices
# PBP .perltidyrc file
# Uncomment #-st to fully emulate perltidy -pbp
-l=78 # Max line width is 78 cols
-i=4 # Indent level is 4 cols
-ci=4 # Continuation indent is 4 cols
#-st # Output to STDOUT
-b # Write the file inline and create a .bak file
-se # Errors to STDERR
@pksunkara
pksunkara / config
Last active June 17, 2025 08:03
Sample of git config file (Example .gitconfig) (Place them in $XDG_CONFIG_HOME/git)
# vi: ft=dosini
[user]
name = Pavan Kumar Sunkara
email = [email protected]
github = pksunkara
[core]
editor = nvim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
pager = delta
[column]
@joubertnel
joubertnel / gist:870190
Last active July 8, 2023 12:52
HTML5 Canvas - Rendering of Text on high-DPI screens
<html>
<head>
<script src='http://code.jquery.com/jquery-1.5.1.min.js'></script>
</head>
<body>
<h2>Naive canvas</h2>
<canvas id="naive" width="400" height="50"></canvas>
<h2>High-def Canvas</h2>
@eligrey
eligrey / strict-typing-examples.js
Last active July 10, 2024 01:39
JavaScript 1.7 Pseudo-Strict Typing
// assignment in function parameters
function sum1 ({Array: numbers}) {
let total = 0; // let {Number: total} = 0; would also be fine
let i = numbers.length;
while (i--) {
let {Number: n} = numbers[i];
total += n;
}