Skip to content

Instantly share code, notes, and snippets.

View city41's full-sized avatar
🙃

Matt Greer city41

🙃
View GitHub Profile
@city41
city41 / gist:958009
Created May 5, 2011 21:32
Get content type from file extension
public string GetContentType(string filename)
{
string mimeType = "application/unknown";
string extension = Path.GetExtension(filename);
if (string.IsNullOrWhiteSpace(extension))
{
return mimeType;
}
@city41
city41 / composite.js
Created January 29, 2012 03:33
Alpha compositing in JavaScript
function _composite(under, over) {
var alphaO = over[3],
alphaU = under[3],
invAlphaO = 1 - alphaO,
i,
len;
for(i = 0, len = under.length - 1; i < len; ++i) {
under[i] = Math.round((over[i] * alphaO)
+ ((under[i] * alphaU) * invAlphaO));
function Vb(d) {
d = d | 0;
var e = 0, f = 0, h = 0, j = 0, k = 0, l = 0, m = 0, n = 0,
o = 0, p = 0, q = 0, r = 0, s = 0;
e = i;
i = i + 12 | 0;
f = e | 0;
h = d + 12 | 0;
j = c[h >> 2] | 0;
if ((j | 0) > 0) {
#!/bin/sh
# Called by "git push" after it has checked the remote status,
# but before anything has been pushed.
#
# If this script exits with a non-zero status nothing will be pushed.
#
# Steps to install, from the root directory of your repo...
# 1. Copy the file into your repo at `.git/hooks/pre-push`
# 2. Set executable permissions, run `chmod +x .git/hooks/pre-push`
@city41
city41 / gist:680c728cdf69ff780c88
Last active August 29, 2015 14:00
Show indentation in Atom
/*
* Your Stylesheet
*
* This stylesheet is loaded when Atom starts up and is reloaded automatically
* when it is changed.
*
* If you are unfamiliar with LESS, you can read more about it here:
* http://www.lesscss.org
*/
@city41
city41 / gist:aab464ae6c112acecfe1
Last active January 19, 2021 12:51
ClojureScript secretary client side navigation without hashes

This is the example that comes with the reagent template converted to use HTML5 based history. This means there are no # in the urls.

I just got this working, so there might be better approaches

The changes are

  • use goog.history.Html5history instead of goog.History
  • listen to clicks on the page, extract the path from them, and push them onto the history
  • listen to history changes, and have secretary do its thing in response
@city41
city41 / gist:e3a822fc4c2d3104443b
Last active August 29, 2015 14:14
cljs :main

project.clj snippet:

:cljsbuild {:builds {:app {:source-paths ["src/cljs"]
                             :compiler {:output-to     "resources/public/js/app.js"
                                        :output-dir    "resources/public/js/out"
                                        :externs       ["react/externs/react.js"]
                                        :main my-app/core
                                        :optimizations :none
 :pretty-print true}}}}
import React from 'react';
import { renderToString } from 'react-dom/server';
import { MockedProvider } from 'react-apollo/test-utils';
export const replaceRenderer = ({ bodyComponent, replaceBodyHTMLString }) => {
const ConnectedBody = () => (
<MockedProvider>
{bodyComponent}
</MockedProvider>
);
@city41
city41 / ardbitmapBug.ino
Created August 26, 2018 15:05
ardbitmap vertical mirror problem
#include <SPI.h>
#include <EEPROM.h>
#include <Arduboy2.h>
#include <math.h>
Arduboy2 arduboy;
#define ARDBITMAP_SBUF arduboy.getBuffer()
#include <ArdBitmap.h>
ArdBitmap<WIDTH, HEIGHT> ardbitmap;