Skip to content

Instantly share code, notes, and snippets.

View DouglasLivingstone's full-sized avatar

Douglas Livingstone DouglasLivingstone

View GitHub Profile
require 'socket'
require 'thread'
require 'net/http'
require 'net/https'
puts "PID: #{$$}"
mode = :debug
if mode == :debug
#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
int a,b ,c,fac,d,rem,g,j,rem_1,e;
char another;
printf("Which one would you like to choose");
printf("\n1. Factorial Of a number \n 2.Prime or not\n 3. Odd or even\n 4. Exit ");
scanf("%d %d %d %d",&a);
@DouglasLivingstone
DouglasLivingstone / gist:6992402
Created October 15, 2013 14:28
Add forename and surname fields to wp-signup.php This is similar to adding fields to wp-login.php?action=register, but it works for multisite WordPress instead. For the original, see: https://codex.wordpress.org/Customizing_the_Registration_Form
<?php
/**
* Plugin Name: Register with Full Name
* Description: Adds forename and surname fields to the registration form
* Version: 0.1
* Author: Douglas Livingstone
*/
//0. Style the new form elements...
@DouglasLivingstone
DouglasLivingstone / onclickoutside.ts
Last active January 19, 2016 14:59
TypeScript OnClickOutsideHandler
// Refactored from https://github.com/Pomax/react-onclickoutside
class OnClickOutsideHandler {
constructor(private localNode: Element, private callback: { (event: Event): void }) {
if (!callback) throw new Error("Missing callback");
document.addEventListener("mousedown", this.eventHandler);
document.addEventListener("touchstart", this.eventHandler);
}
@DouglasLivingstone
DouglasLivingstone / FluxActions.ts
Created October 15, 2015 09:00
Type-checking Flux actions in TypeScript
interface ActionClass<T extends Action> {
prototype: T;
}
// Base class for actions
abstract class Action {
type: string;
constructor() {
// Copy from the prototype onto the instance
this.type = this.type;
@DouglasLivingstone
DouglasLivingstone / DefaultDictionary.cs
Created September 21, 2018 20:35
DefaultDictionary for C#
class DefaultDictionary<Key, Value> : Dictionary<Key, Value> {
public new Value this[Key key]
{
get
{
if (!ContainsKey(key))
{
base[key] = default(Value);
}
return base[key];