Skip to content

Instantly share code, notes, and snippets.

View patrickodacre's full-sized avatar

Patrick O'Dacre patrickodacre

View GitHub Profile
@patrickodacre
patrickodacre / taxonomy.sql
Created March 22, 2023 15:06 — forked from arpitbbhayani/taxonomy.sql
Quickly populate random 5 million + rows in a taxonomy using SQL
# create table topics!
create table topics (
id int primary key auto_increment,
name varchar(256),
parent_id int null,
type smallint not null,
foreign key (parent_id) references topics(id),
index(type)
);
#include "SDL2/SDL.h"
#include "SDL2/SDL_mixer.h"
static const char *MY_COOL_MP3 = "cool_tunes.mp3";
int main(int argc, char **argv) {
int result = 0;
int flags = MIX_INIT_MP3;
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
@patrickodacre
patrickodacre / string-conversion.rs
Created May 8, 2021 01:23 — forked from jimmychu0807/string-conversion.rs
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@patrickodacre
patrickodacre / README.md
Created December 4, 2017 19:19 — forked from hofmannsven/README.md
My simply MySQL Command Line Cheatsheet
@patrickodacre
patrickodacre / what-forces-layout.md
Created June 15, 2016 15:41 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
@patrickodacre
patrickodacre / Navigation.php
Created October 22, 2015 21:14 — forked from aaroneaton/Navigation.php
Using the Zurb Foundation Top Bar with WordPress menus
<?php
class Navigation {
public function __construct() {
// Move the navigation to the header element
remove_action( 'genesis_after_header', 'genesis_do_nav' );
remove_action( 'genesis_site_title', 'genesis_seo_site_title' );
// remove_action( 'genesis_header', )
add_action('wp_loaded','webendev_register_nav_menu_class');
/**
* New walker class to extend Walker_Nav_Menu
* Dynamically adds child categories to menu
*
*/
function webendev_register_nav_menu_class(){
class Submenu_Walker_Nav_Menu extends Walker_Nav_Menu {
# -----------------------------------------------------------------
# .gitignore for WordPress @salcode
# ver 20150227
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/salcode/b515f520d3f8207ecd04/raw/.gitignore
# to download this file
#
# By default all files are ignored. You'll need to whitelist
# any mu-plugins, plugins, or themes you want to include in the repo.
@patrickodacre
patrickodacre / 0_reuse_code.js
Created April 14, 2014 20:37
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console