This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.toCamel = function () { | |
return this.replace(/(_[a-zA-Z])/g, function ($1) { | |
return $1.toUpperCase().replace('_', ''); | |
}); | |
}; | |
String.prototype.toUnderscore = function () { | |
return this.replace(/([A-Z])/g, function ($1) { | |
return "_" + $1.toLowerCase(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function addAll_VariadicFunction(...$rest) | |
{ | |
return array_reduce($rest, function ($a, $b) { | |
return $a + $b; | |
}); | |
} | |
function add_SimpleReduce($a, $b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hello geoff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create (connect to) SQLite database in file | |
$file_db = new PDO('sqlite:/usr/local/etc/tarbackup/db/tarbackup.db'); | |
// Set errormode to exceptions | |
$file_db->setAttribute(PDO::ATTR_ERRMODE, | |
PDO::ERRMODE_EXCEPTION); | |
// Array with some test data to insert to database | |
$users = array( | |
array('Name' => $name, | |
'Password' => crypt512($password), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$myFile = "/usr/local/etc/tarbackup/userstocreate.txt"; | |
$fh = fopen($myFile, 'a') or die("can't open file"); | |
$stringData = $name . ":" . crypt512($password) . ":" . $email . "\n"; | |
fwrite($fh, $stringData); | |
fclose($fh); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import sqlite3 as lite | |
import sys | |
import os | |
def get_users_to_create(): | |
con = None | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use File::Copy; | |
$dir = "/usr/local/etc/tarbackup/"; | |
$logfilename = $dir . "createdusers.log"; | |
$infilename = $dir . "userstocreate.txt"; # the queue of users that have signed up since last run | |
copy($infilename, $infilename . ".copy"); # make a copy to make this process as atomic as possible | |
#delete and recreate the existing file with the same permissions | |
unlink($infilename); | |
open NEWFILE, ">$infilename" or die $!; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import sqlite3 as lite | |
import sys | |
def get_users(): | |
with open("createdusers.log") as f: | |
users = [] | |
lines = f.readlines() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir /backups | |
cd /backups/ | |
tar -cvpzf fullbackup.tar.gz --directory=/ --exclude=proc --exclude=sys --exclude=dev/pts --exclude=backups . |