Skip to content

Instantly share code, notes, and snippets.

Chris Wright DaveRandom

Block or report user

Report or block DaveRandom

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@DaveRandom
DaveRandom / login.php
Created Aug 19, 2018 — forked from rahuldottech/login.php
PHP session management
View login.php
<?php
require 'secsesh.php';
session_start();
if(/*credentials check out*/){
s_start();
}
header( 'Location: somePage.php' );
View y_u_no_chat_nice.js
(function() {
'use strict';
/**
* Modifications to perform (processed in order)
*
* @type {Function[]}
*/
const modifications = [
(text) => text.replace(/!+/g, '!'),
@DaveRandom
DaveRandom / rant.md
Last active Aug 18, 2018
Why you should not use relative paths when working with files in PHP
View rant.md

TL;DR do what the last section tells you to do

What is the difference between a relative path and an absolute path?

An absolute path is one which includes all path components from the root of the file system. It starts with a leading / on unix-like operating systems, or a drive letter on Windows.

Unix: /full/path/to/file.php
Windows C:\full\path\to\file.php
View SeededRandomNumberGenerator.php
<?php
class SeededRandomNumberGenerator
{
/**
* An integer with the 32 least significant bits set
* 0xffffffff is a float on 32-bit platforms :-/
*/
private const MASK = \PHP_INT_SIZE === 4 ? ~0 : 0xffffffff;
View hash-many.php
<?php
include dirname(__DIR__) . "/vendor/autoload.php";
use Amp\Process\Process;
use function Amp\Promise\all;
const COUNT = 8;
$passwords = [];
@DaveRandom
DaveRandom / readme.md
Last active Jul 21, 2017
Adding projects to OpenGrok on lxr.room11.org
View readme.md

Adding projects to OpenGrok on lxr.room11.org

Connecting to the server

SSH to lxr.room11.org. The server requires public key authentication, contact a room owner to have your key added.

Adding a project

Check out the sources from git into /srv/sources. The directory name will appear in the OpenGrok web interface, so choose a sensible directory name! Please use https:// URLs for the remote where possible.

@DaveRandom
DaveRandom / script.js
Last active Jun 6, 2018
Tweet icon for Jeeves in SO chat
View script.js
// ==UserScript==
// @name Tweet icon for Jeeves in SO chat
// @namespace http://room11.org/
// @version 1.0
// @description @PeeHaa sucks
// @author @DaveRandom
// @match *://chat.stackoverflow.com/rooms/*
// @grant none
// ==/UserScript==
@DaveRandom
DaveRandom / Draytek Google Domains DDNS Dynamic DNS Config.md
Last active Nov 11, 2019
Draytek Google Domains DDNS Dynamic DNS Config
View Draytek Google Domains DDNS Dynamic DNS Config.md

How to configure a Draytek router to update your dynamic DNS record with Google Domains

Draytek Dynamic DNS Configuration Page

  1. Choose the "WAN Interface" strategy to use when determining the IP address used when performing updates.
  2. In the "Service Provider" field, choose "User Defined". Additional configuration fields appear.
  3. In the "Provider Host" field, enter domains.google.com
  4. In the "Service API" field, enter /nic/update?myip=###IP###&hostname=your.hostname.here, replacing "your.hostname.here" with the fully qualified name of the record you wish to dynamically update.
  5. In the "Auth Type" field, choose "Basic" (this is the default).
  6. In the "Connection Type" field, choose "HTTPS".
View client.php
<?php declare(strict_types = 1);
function send_data($socket, $data)
{
echo "Sending data {$data}\n";
fwrite($socket, $data);
$response = fread($socket, 1024);
echo "Got response: {$response}\n";
}
View gist:bba879796566e4e88d785e84a1db4971
array(97) { ["PROCESSOR_ARCHITEW6432"]=> string(5) "AMD64" ["_FCGI_X_PIPE_"]=> string(53) "\\.\pipe\IISFCGI-c9b24bea-eef1-4a1d-b0a5-a94ab18c4deb" ["PHP_FCGI_MAX_REQUESTS"]=> string(5) "10000" ["PHPRC"]=> string(31) "C:\Program Files (x86)\PHP\v5.3" ["ALLUSERSPROFILE"]=> string(14) "C:\ProgramData" ["APPDATA"]=> string(56) "C:\Windows\system32\config\systemprofile\AppData\Roaming" ["APP_POOL_CONFIG"]=> string(51) "C:\inetpub\temp\apppools\SingleRTB\SingleRTB.config" ["APP_POOL_ID"]=> string(9) "SingleRTB" ["CommonProgramFiles"]=> string(35) "C:\Program Files (x86)\Common Files" ["CommonProgramFiles(x86)"]=> string(35) "C:\Program Files (x86)\Common Files" ["CommonProgramW6432"]=> string(29) "C:\Program Files\Common Files" ["COMPUTERNAME"]=> string(15) "WIN-IAHBJGOU4S1" ["ComSpec"]=> string(27) "C:\Windows\system32\cmd.exe" ["FP_NO_HOST_CHECK"]=> string(2) "NO" ["JRE_HOME"]=> string(32) "C:\Program Files (x86)\Java\jre7" ["LOCALAPPDATA"]=> string(54) "C:\Windows\system32\config\systemprofile\AppData\Local" ["NU
You can’t perform that action at this time.