Skip to content

Instantly share code, notes, and snippets.

@Natinux
Natinux / jsonp.js
Last active August 29, 2015 14:27 — forked from gf3/jsonp.js
Simple JSONP in vanilla JS
/**
* loadJSONP( url, hollaback [, context] ) -> Null
* - url (String): URL to data resource.
* - hollaback (Function): Function to call when data is successfully loaded,
* it receives one argument: the data.
* - context (Object): Context to invoke the hollaback function in.
*
* Load external data through a JSONP interface.
*
* ### Examples
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Jasmine Spec Runner v2.0.0</title>
<link rel="shortcut icon" type="image/png" href="lib/jasmine-2.0.0/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="lib/jasmine-2.0.0/jasmine.css">
<script type="text/javascript" src="lib/jasmine-2.0.0/jasmine.js"></script>
//return an array of objects according to key, value, or key and value matching
function getObjects(obj, key, val) {
var objects = [];
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (typeof obj[i] == 'object') {
objects = objects.concat(getObjects(obj[i], key, val));
} else
//if key matches and value matches or if key matches and value is not passed (eliminating the case where key matches but passed value does not)
if (i == key && obj[i] == val || i == key && val == '') { //
@Natinux
Natinux / embed_ttf.c
Created September 8, 2013 12:25
This program will quickly and automatically set the font to 'installable embedding allowed', the least restrictive setting. You can use Microsoft's editor to make it a more restrictive value, or change it in the source code, if you really require a different embedding level. To run it, simply give it the name of the ttf file on the command line:…
#include <stdio.h>
#include <stdlib.h>
void fatal();
int main (int argc, char**argv) {
FILE * inways;
if (argc != 2)
printf("Usage: %s font.ttf\n\nPublic Domain software by Tom 7. Use at your own risk.\n",argv[0]);
else if (inways = fopen(argv[1],"rb+")) {