Skip to content

Instantly share code, notes, and snippets.

View frekw's full-sized avatar
🐼

Fredrik Wärnsberg frekw

🐼
  • https://www.soundtrackyourbrand.com/
  • Stockholm, Sweden
  • 13:13 (UTC +02:00)
View GitHub Profile
@jlongster
jlongster / kh.el
Last active October 28, 2015 20:23
(defun keynote-highlight ()
(interactive)
(shell-command-on-region
(region-beginning)
(region-end)
"highlight -O rtf --font-size 36 --font Inconsolata --style solarized-dark -W -J 50 -j 3 --src-lang ruby | pbcopy"))
const redux = require('./redux');
const ReactInstanceMap = require('react/lib/ReactInstanceMap');
function getIdFromInstance(instance) {
const internalInstance = ReactInstanceMap.get(instance);
return internalInstance ? internalInstance._rootNodeID : null;
}
function allocate(store, id, initialState) {
const atomState = store.getState();
@kimroen
kimroen / high-dpi-media.scss
Created November 20, 2012 10:24 — forked from marcedwards/high-dpi-media.css
A Sass media query mixin that captures almost all high DPI aware devices.
/* ----------------------------------------------------------------------- */
/* */
/* Improved upon a mixin from 37signals and combined */
/* with these numbers from marc. */
/* */
/* 37signals-version: */
/* http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss */
/* */
/* @kimroen */
/* */
@hxgdzyuyi
hxgdzyuyi / backbone-mixin.js
Created September 6, 2012 08:21 — forked from dmitry/backbone-mixin.js
Merge backbone views (mixin pattern)
define('backbone', ['lib-underscore', 'lib-backbone'], function () {
Backbone.mixin = function (view, mixin, custom) {
if (custom) {
if (custom.events && mixin.events) {
mixin = _.clone(mixin)
_.defaults(custom.events, mixin.events)
}
_.extend(mixin, custom)
}
var source = view.prototype || view
@mjangda
mjangda / cli-ms-upgrade.php
Created May 23, 2011 15:04
Command Line script to upgrade a WordPress Multisite instance
<?php
/**
* WordPress Multisite upgrade script
*
* IMPORTANT: While a simple safeguard has been added to the script,
* you'll want to add another layer that prevents this script from
* being called via the browser.
*
* Usage:
* 1) Place in the root of your install (or another place, but modify the wp-load.php path to match)
@xjamundx
xjamundx / uploadapp.js
Created January 18, 2012 04:45
file uploads with express and node.js
// middleware
app.use(express.bodyParser({ keepExtensions: true, uploadDir: __dirname + "/public/uploads" }))
// later
app.get('/photos', uploadFile, addPhoto)
// file is automatically saved to /public/uploads, let's just set
function uploadFile(req, res, next) {
if (req.files) {
req.body.url = "http://myawesomesite.com/" + req.files.file.path.split("/").slice(-2).join("/")
@travisbrown
travisbrown / deusaquilus-deleted-tweets.md
Created November 8, 2021 04:34
Deleted tweets by Alexander Ioffe

Deleted tweets for deusaquilus

The list below includes 510 deleted tweets by deusaquilus.

There are also 3 tweets that are indicated as not currently deleted by the Twitter API that have been scraped from pages of deleted tweets (as replies, etc.). These possibly undeleted tweets are included for context and are indicated by a (live) link.

@orenbenkiki
orenbenkiki / enhanced_extension.ex
Last active February 21, 2022 22:29
Elixir module inheritance
defmodule Extension do
defmacro extends(module) do
# As above...
end
defmacro implements(module, protocol: protocol) do
quote do
defimpl unquote(protocol), for: unquote(module) do
import Extension
@macournoyer
macournoyer / Output
Last active January 9, 2023 15:12
A Neural Network framework in 25 LOC
$ python xor.py
Training:
Epoch 0 MSE: 1.765
Epoch 100 MSE: 0.015
Epoch 200 MSE: 0.005
* Target MSE reached *
Evaluating:
1 XOR 0 = 1 ( 0.904) Error: 0.096
0 XOR 1 = 1 ( 0.908) Error: 0.092
1 XOR 1 = 0 (-0.008) Error: 0.008
@sebmarkbage
sebmarkbage / Enhance.js
Last active January 31, 2024 18:33
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {