Skip to content

Instantly share code, notes, and snippets.

<!doctype html>
<div style="display: flex; flex-flow: column; height: 400px; width: 300px; border: 1px solid green">
<div style="padding: 20px; background-color: teal; color: white;"> This is some sort of heading</div>
<div style="border: 1px solid red; overflow: auto;">
this is the body
<br>
this is the body
<br>
this is the body
<br>
<!doctype html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/preact/8.2.7/preact.dev.js"></script>
<div id="app"></div>
<script>
var app = {
color: "#00ffff",
}
function changeColor(e) {
@drewlesueur
drewlesueur / index.html
Last active November 17, 2017 18:15
Vue.js two ways to do event handling
<!DOCTYPE html>
<div id=app>
<my-button text=Hello :myonclick="() => foo('yo')" @mymouseenter=foo2></my-button>
</div>
<script src="https://unpkg.com/vue/dist/vue.min.js"></script>
<script>
Vue.component('my-button', {
props: ['text', 'myonclick'],
template: '<button type="button" class="btn" @click="myonclick" @mouseenter="doMouseEnter">{{ text }}</button>',
methods: {
https://github.com/drewlesueur/php-src/tree/7568605b55189cbc5fedd6dff3da074f9abf1d6d
<!doctype html>
<html>
<head>
</head>
<body>
<div style="height: 400px; border: 1px solid green; width: 300px; display: flex; flex-flow: column nowrap; ">
<div style="padding: 20px; background-color: orange; ">I am a header</div>
<div style="flex: 1 1 auto; display: flex; flex-flow: column nowrap; overflow: auto;">
function scale(x, realMin, realMax, scaledMin, scaledMax) {
var realDiff = realMax - realMin
var scaledDiff = scaledMax - scaledMin
var xOffset = x - realMin
var ratio = xOffset / realDiff
var appliedValue = ratio * scaledDiff
var ret = scaledMin + appliedValue
return ret
}
var ifs = function (args, i) {
var i = i || 0;
if (i == args.length - 1) { return args[i] }
else if (i > args.length - 1) { return undefined }
if (args[i]) { return args[i + 1] }
else { return ifs(args, i + 2) }
}
@drewlesueur
drewlesueur / javascripts_this.js
Last active December 18, 2015 18:09
Javascript's this
var a = {name: "a", fun: function () { return this; }};
console.log(a.fun());
//=> {name "a", fun: ...}
var bFunc = function () { return this };
var b = {name: "b", fun: bFunc};
console.log(b.fun());
//=> {name: "b", fun: ...}
// not some global object
// alternate to imagecreatefrom...
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$image = curl_exec($ch);
curl_close($ch);
// code taken from visionmedias node-querystring
var qs = (function () {
var qs = {}
/**
* Object#toString() ref for stringify().
*/
var toString = Object.prototype.toString;
/**