Skip to content

Instantly share code, notes, and snippets.

@zyphlar
zyphlar / generatePassword.php
Created December 20, 2014 22:36
Generating secure passwords in PHP
View generatePassword.php
<?php
// usage: $newpassword = generatePassword(12); // for a 12-char password, upper/lower/numbers.
// functions that use rand() or mt_rand() are not secure according to the PHP manual.
function getRandomBytes($nbBytes = 32)
{
$bytes = openssl_random_pseudo_bytes($nbBytes, $strong);
if (false !== $bytes && true === $strong) {
return $bytes;
}
@zyphlar
zyphlar / qgis-getstreetfromaddress.py
Created August 31, 2022 23:45
QGIS user expression to separate and format streets from addresses
View qgis-getstreetfromaddress.py
from qgis.core import *
from qgis.gui import *
@qgsfunction(args='auto', group='Custom', referenced_columns=[])
def getstreetfromaddress(value1, feature, parent):
parts = value1.split()
parts.pop(0) # Ignore the first bit (i.e. "123" in "123 N MAIN ST")
parts = map(formatstreetname, parts)
return " ".join(parts)
View controller.php
<?php
//..
function editAction(){
$form = $this->createForm(new Forms\UserType($userConfig), $user);
$form->handleRequest($request);
if($form->isValid()) {
$em = $this->getDoctrine()->getManager();
@zyphlar
zyphlar / cylon.sh
Created December 9, 2021 19:22
cylon/loop led scanner flasher routine in bash
View cylon.sh
led0path=/sys/class/leds/$SOME_LED_HERE/brightness
led1path=/sys/class/leds/$SOME_LED_HERE/brightness
led2path=/sys/class/leds/$SOME_LED_HERE/brightness
run=1
led=0
up=1
minled=0
@zyphlar
zyphlar / gist:b980f22b9b2c47935628
Last active December 9, 2021 17:46
Talking about makerspace management and hackerspaces
View gist:b980f22b9b2c47935628
11:31 AM <LesaraRose> Sorry. I have a lot of questions lol
11:33 AM <TheWill> hardest: inspiring volunteers. work: being everybody's surrogate parent because they were ~20yo and antisocial and didn't know how to avoid generating a storm of drama everywhere they go
11:34 AM <TheWill> the idea of "everybody contributes towards the common good" is great until you're dealing with people who can't resolve the "who washes the dishes" conflict with their roommate
11:35 AM <TheWill> in other words a balance of demographics is vastly superior even if less comfortable
11:36 AM <TheWill> having a paid community manager is in my opinion the most effective way to reduce drama
11:36 AM <TheWill> and burnout
11:40 AM <myself> Hardest: Getting our external image to reflect the diversity of stuff actually happening in the space. Our technical people get more attention than our artistic people, so it takes a lot of work to bring in more artistic people. Yet, when we take both technical and artistic projects to show off at an e
@zyphlar
zyphlar / chimera-bylaws.txt
Created April 23, 2020 23:23
chimera bylaws
View chimera-bylaws.txt
Bylaws of
Chimera Art Space
Article 1 - Offices
Section 1. Principal Office
The principal office of the corporation is located in Sonoma County, State of California.
Section 2. Change of Address
The designation of the county or state of the corporation's principal office may be changed by amendment of these bylaws. The board of directors may change the principal office from one location to another within the named county by noting the changed address and effective date below, and such changes of address shall not be deemed, nor require, an amendment of these bylaws:
@zyphlar
zyphlar / asterisk-logfile-analyzer.php
Created June 26, 2012 10:19
Cheap and Dirty Asterisk Logfile Analysis
View asterisk-logfile-analyzer.php
<?php
/* Cheap and Dirty Asterisk Logfile Analysis
* by Will Bradley, http://willbradley.name
* Released to the public domain, 6-26-2012
*
* To install, modify the $dbname and other variables,
* create the MySQL database, user, and permissions,
* and double-check the asterisk logfile paths/formats below.
* This is a very cheap script, use at your own risk!
*
@zyphlar
zyphlar / rgb-hsv-conversion.php
Created October 21, 2014 22:22
RGB and HSV conversion in PHP
View rgb-hsv-conversion.php
<?php
// note: some of these are written with $this so they work inside classes.
// you could easily rewrite this to be a general function outside a class.
// sorry for the inconsistent tabs
// adapted from: http://www.actionscript.org/forums/showthread.php3?t=50746 via http://stackoverflow.com/questions/1773698/rgb-to-hsv-in-php
class MyClass
{
// usage: $this->hexColorMod("#aa00ff", -0.2); // darker by 20%
// returns: #8700cc
@zyphlar
zyphlar / dynamic-thermometer.html
Created December 22, 2019 22:49
dynamic fundraising thermometer from google docs / spreadsheet
View dynamic-thermometer.html
<!doctype>
<html>
<head>
<script type="text/javascript">
var sheetPublicWebUrl = "https://docs.google.com/spreadsheets/d/e/2PACX-1vSbdn0eDQHBJuC3X8C4Lrmgwsomj5c4K-5x8ROhCkylVNeA5dtCq59wavQcgzmGt8qplXgUBHq-NZEj/pub?gid=0&single=true&range=b1&output=csv"
var req = new XMLHttpRequest();
req.open('GET', sheetPublicWebUrl, true);
req.onload = function() {
result = req.responseText;
@zyphlar
zyphlar / detect_signal.grc
Created May 22, 2019 03:21
Trying to detect when there's a signal on a frequency
View detect_signal.grc
<?xml version='1.0' encoding='utf-8'?>
<?grc format='1' created='3.7.11'?>
<flow_graph>
<timestamp>Tue May 21 15:46:50 2019</timestamp>
<block>
<key>options</key>
<param>
<key>author</key>
<value></value>
</param>