Skip to content

Instantly share code, notes, and snippets.

View Lewiscowles1986's full-sized avatar
🤓

Lewis Cowles Lewiscowles1986

🤓
View GitHub Profile
@Lewiscowles1986
Lewiscowles1986 / dhcpcd.sh
Created August 21, 2017 16:00
Raspberry pi stretch allow dhcpcd5 with /etc/network/interfaces
#!/bin/sh -e
#
# This file belongs in /usr/lib/dhcpcd5/dhcpcd how you get it there is up to you
#
DHCPCD=/sbin/dhcpcd
INTERFACES=/etc/network/interfaces
REGEX="^[[:space:]]*iface[[:space:]](*.*)[[:space:]]*inet[[:space:]]*(dhcp|static)"
EXCLUDES=""
@dianewallace
dianewallace / woo-no-shipping-available-message.php
Last active November 17, 2020 17:42
Update the Woocommerce No Shipping message to include contact details.
add_filter( 'woocommerce_cart_no_shipping_available_html', 'myplugin_no_shipping_available_message' );
add_filter( 'woocommerce_no_shipping_available_html', 'myplugin_no_shipping_available_message' );
/**
* Update the Woocommerce No Shipping message to include contact details.
*/
function myplugin_no_shipping_available_message( $message ) {
$country = WC()->customer->get_shipping_country();
$mailto = 'mailto:' . get_option( 'admin_email' ); // Could also be 'woocommerce_stock_email_recipient'.
$link = sprintf( wp_kses( __( '<a href="%s">contact us</a>', 'my-plugin' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( $mailto ) );
@vipickering
vipickering / closestNumberArray.js
Created September 13, 2013 15:42
Javascript: Find The Closest Number In Array To A Specific Value
var array = [];
function closest(array,num){
var i=0;
var minDiff=1000;
var ans;
for(i in array){
var m=Math.abs(num-array[i]);
if(m<minDiff){
minDiff=m;
@amcgregor
amcgregor / 00-irc-log.textile
Created August 10, 2011 02:03
Where asking a simple question, and not accepting useless and insulting answers, gets you banned from an IRC channel.

Cleaned IRC log of #python starting Monday, 25 July, 2011 at 17:13:55 EDT.

Gems are highlighted in bold.

GothAlice How do I determine if a given object is a @classmethod, and, additionally, how do I determine if it is a @staticmethod? 1
KirkMcDonald GothAlice: Why would you care?
GothAlice KirkMcDonald: Enforcing interfaces, not that it matters.
dash GothAlice: you’re right, it doesn’t matter
_habnabit GothAlice, if you wanted an answer to the question as asked, why don’t you try ##python-friendly? #python is about writing better code.
nedbat GothAlice: what KirkMcDonald should have said was, “The Python culture is to not check ahead of time, do you have an unusual requirement that means you really have to know?”
@denniswebb
denniswebb / swagger-ui.tf
Created October 11, 2016 02:55
Terraform template for deploying Swagger-UI to S3 website.
variable "region" {default = "us-west-2"}
variable "website_dns" {default = "swagger-ui.webblab.info"}
variable "r53_zone_id" {default = "Z1S59LUERGUH56"}
variable "swagger_ui_version" {default = "v2.2.5"}
provider "aws" {
region = "${var.region}"
}
resource "aws_s3_bucket" "main" {
/* So how does this work?
I'm using ANSI escape sequences to control the behavior of the terminal while
cat is outputting the text. I deliberately place these control sequences inside
comments so the C++ compiler doesn't try to treat them as code.*/
//
/*The commands in the fake code comment move the cursor to the left edge and
clear out the line, allowing the fake code to take the place of the real code.
And this explanation uses similar commands to wipe itself out too. */
//
#include <cstdio>
@marcosci
marcosci / render_universe.R
Created December 8, 2021 07:54
Rayrender Universe
library(rayrender)
library(glue)
y_dist = 8
circle <- function(x = 0, y = 0 + 20, rad = 1, nvert = 500, ...){
rads <- seq(0,2*pi,length.out = nvert)
xcoords <- cos(rads) * rad + x
ycoords <- sin(rads) * rad + y
cbind(x = xcoords, y = y_dist, z = ycoords)
@mntmn
mntmn / osx_framebuffer
Created December 21, 2013 15:49
probably the quickest way to draw pixels on OSX in C. catch: compiles only with -m32 (32 bit arch). :|
#include <Carbon/Carbon.h>
#include <CoreGraphics/CoreGraphics.h>
uint32_t framebuffer[FB_W*FB_H];
WindowRef osx_window;
CGContextRef osx_window_context;
CGContextRef osx_bitmap_context;
void updateFrameBuffer() {
@shark0der
shark0der / setup_mailcatcher.sh
Last active January 22, 2022 16:28 — forked from conroyp/setup_mailcatcher.sh
Mailcatcher installation script for Ubuntu 16.04 (14.04 commands commented out)
#!/bin/bash
# Install dependencies
# older ubuntus
#apt-get install build-essential libsqlite3-dev ruby1.9.1-dev
# xenial
apt install build-essential libsqlite3-dev ruby-dev
# Install the gem
gem install mailcatcher --no-ri --no-rdoc
@mmcdaris
mmcdaris / R2G_to_local.md
Created March 21, 2017 22:09
Replicate from REDISTOGO to your local machine

example RTG_URL: redis://username:secretpasswordfromtheurl@lab.redistogo.com:9555/

Step 1: Start a local redis-server and redis-cli

$ redis-server
#in a new tab run:
$ redis-cli