Skip to content

Instantly share code, notes, and snippets.

View jsylvanus's full-sized avatar
🕶️

James Sylvanus jsylvanus

🕶️
View GitHub Profile
@jsylvanus
jsylvanus / TODO.md
Last active January 5, 2019 20:07
Structs in PHP. Work in progress.

PHP Struct Trait

This should really be a C extension but this is an OK prototype of the concept. Structs in PHP!

TODO

  • Add magic setter to enforce type safety.
  • Like, maybe typed arrays?
  • Probably static caching the reflection info so we don't have to do the reflection dance on each instantiation.
@jsylvanus
jsylvanus / spatial_hash.h
Created January 22, 2017 16:24
I don't know, I thought writing a generic spatial hash in C would be a good idea.
#pragma once
#include <stdint.h>
#include <stdlib.h>
typedef struct spatial_hash_s {
uint32_t width;
uint32_t height;
uint16_t cellmax; // max # of entries per cell
uint64_t entrysize; // size of a single entry
@jsylvanus
jsylvanus / gist:caec49dd76b6299f935b
Last active April 26, 2018 20:19
Squint test w/ BLOKK font
" Throw me in your ~/.gvimrc
let g:squinty = 0
function! Squint()
let windowBounds = system("osascript -e 'tell application \"MacVim\" to get bounds of window 1'")[:-2]
if g:squinty
set guifont=InputMonoCondensed_Thin:h14
let g:squinty = 0
else
set guifont=BLOKK:h6
@jsylvanus
jsylvanus / .gitconfig
Created December 19, 2014 18:25
Git config aliases
[alias]
meatloaf = archive -o meatloaf.zip HEAD
lsl = log --oneline --decorate --graph --all
ds = diff --staged
st = status -sb
fup = log --since '1 day ago' --oneline --author [email protected]
rhh = reset --hard HEAD
hist = log --color --pretty=format:\"%C(yellow)%h%C(reset) %s%C(bold red)%d%C(reset) %C(green)%ad%C(reset) %C(blue)[%an]%C(reset)\" --relative-date --decorate
# basic
@jsylvanus
jsylvanus / ObjectCycler.coffee
Created December 19, 2014 18:16
ObjectCycler class (basic cyclical list behavior) - good for sliders
class window.ObjectCycler
constructor : ( data = [] ) ->
if typeof data is 'string'
if typeof jQuery isnt 'undefined' # this implies a jquery selector
data = jQuery(data).toArray()
else
throw new Error 'jQuery must be available to construct with a selector.'
@data = data
@index = 0
@jsylvanus
jsylvanus / Timer.coffee
Last active August 29, 2015 14:11
simple Timer class written in coffee script
class window.Timer
ref : null
callback : null
constructor: ( @frequency, @callback, @running = yes ) ->
@start() if @running
start: ->
@stop() if @ref isnt null
@jsylvanus
jsylvanus / pre-commit
Created February 25, 2014 19:37
pre-commit hook to not allow user to commit broken php files
#!/usr/bin/env bash
result=`find . -type f -iname '*.php' -exec php -l {} \; 2>&1 1> /dev/null`
if [ ! -z "$result" ]; then
echo "Found errors in your PHP files, refusing to commit." 1>&2
echo $result 1>&2
exit 1
fi
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
@jsylvanus
jsylvanus / example.scss
Last active December 19, 2015 23:59
SCSS input placeholder mixin and usage example
#filter-search-query {
@include border-radius(0.75em);
width:100%;
border:1px solid #d8d8d8;
padding:0.3em 0.9em;
@include placeholder { // placeholder usage
color:#eee;
font-family:$sans-serif;
&:before {
font-family:$icon-font;