Skip to content

Instantly share code, notes, and snippets.

@piccaso
piccaso / drupal-7-patch-SA-CORE-2014-005-D7.sh
Created October 18, 2014 15:12
patching Drupal 7 SA-CORE-2014-005-D7
wget -O /tmp/SA-CORE-2014-005-D7.patch https://www.drupal.org/files/issues/SA-CORE-2014-005-D7.patch && chmod 0600 /tmp/SA-CORE-2014-005-D7.patch
cd /var/www
find -path '*/includes/database/database.inc'
#make backups
for f in $( find -path '*/includes/database/database.inc' ); do cp -av $f $f.backup-$(date +"%Y-%m-%d-%H%M%S"); done
#dry run
for f in $( find -path '*/includes/database/database.inc' ); do patch --dry-run $f < /tmp/SA-CORE-2014-005-D7.patch; done
@piccaso
piccaso / openscad-sinus-animation.scad
Last active August 29, 2015 14:15
Using sinus for animation in OpenSCAD
/* result: http://i.imgur.com/PfutWmN.gif */
t=sin($t*180); /* $t==0 && t==0, $t==0.5 && t==1, $t==1 && t==0 */
n=t*.5;
for(l = [0:3]){ /* = 4 layers */
translate([n*(1.1*l)+(.1*l),0,0]) cube([.1,1,1]);
}
'use strict';
angular.module("ngLocale", [], ["$provide", function($provide) {
var PLURAL_CATEGORY = {ZERO: "zero", ONE: "one", TWO: "two", FEW: "few", MANY: "many", OTHER: "other"};
function getDecimals(n) {
n = n + '';
var i = n.indexOf('.');
return (i == -1) ? 0 : n.length - i - 1;
}
function getVF(n, opt_precision) {
<!DOCTYPE>
<html>
<head>
<title>Selenium Test Example Page</title>
</head>
<body style="margin: 20px" onload="checkParams()">
<h2>Selenium Test Example Page</h2>
<p id="intro">
@piccaso
piccaso / 0_reuse_code.js
Last active August 29, 2015 14:20
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
# curl https://gist.githubusercontent.com/piccaso/431d30e5c979e3d2ba1f/raw | bash
# related: http://bit.ly/1AJNMRA http://git.io/vk9it
# clone somewhere...
cd `mktemp -d` && git clone https://git.typo3.org/Packages/TYPO3.CMS.git && cd TYPO3.CMS/
{
# setup/reset
WORKINGBRANCH="TYPO3_7-0"
jQuery(document).ready(function($){
'use strict';
function nurseLinks(){
$('a').each(function(i,e){
function trySel(sel){
if($(sel).length > 0){ $(e).attr('href', sel); return true; }
return false;
}
var h = e.hash.toString().match(/^#.+/);
@piccaso
piccaso / img2linkedvmdk.bat
Created July 29, 2015 17:34
create a linked vmdk for a raw (dd style) disk image - acts like a real drive
VBoxManage.exe internalcommands createrawvmdk -filename "%1-linked.vmdk" -rawdisk "%1"
@pause
@piccaso
piccaso / gist:2603879
Created May 5, 2012 16:37
parsing dd.mm.yyyy hh:ss (tt.mm.jjjj ss:mm) date (used in austria)
<?php
function parse_austrian_date($date,$output='U'){
$date = DateTime::createFromFormat('d.m.Y H:i', $date);
if($date === false) return false;
return $date->format($output);
}
echo parse_austrian_date('1.2.12 24:14','d.m.Y H:i:s');