Skip to content

Instantly share code, notes, and snippets.

View hugows's full-sized avatar
🏠
Working from home

Hugo Schmitt hugows

🏠
Working from home
View GitHub Profile
function makeStyle(defaults, tagName) {
tagName = tagName || 'div';
var Style = React.createClass({
getDefaultProps: function() {
return assign({}, defaults);
},
render: function() {
var style = assign({}, this.props);
delete style.children;
@cecilemuller
cecilemuller / js_createclass.js
Last active June 5, 2018 16:04
React: "JSX + ES class" vs "Vanilla JS + createClass"
// Non-JSX and React.createClass
import {createClass, createElement, PropTypes} from 'react';
import css from './Application.css';
export default createClass({
displayName: 'Application',
propTypes: {
title: PropTypes.string
},
handleClick(): void {
@pervognsen
pervognsen / btree.inl
Last active June 15, 2019 17:23
Experiments in lightweight C templates
// Here is btree.inl, which is the thing you would write yourself.
// Unlike C++ templates, the granularity of these lightweight templates is at the
// module level rather than the function or class level. You can think of it like
// ML functors (parameterized modules) except that there isn't any static checking
// of signatures (in that respect, it's like C++ templates). In my view, this style
// of parameterized generative modules is generally the better conceptual framework.
// This is a completely valid C file even prior to preprocessing, so during library
// development you can just include this file directly. That is a big win for testing
@shaunlee
shaunlee / dblayer.go
Last active January 28, 2020 19:24
Golang database layer
package main
import (
"fmt"
"strings"
"database/sql"
)
const (
SQL_INSERT = "INSERT INTO %s (%s) VALUES (%s)"
@magbicaleman
magbicaleman / index.js
Last active May 6, 2020 19:21
Crude Dynamic Import Example on Create React App index.js scaffold
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import registerServiceWorker from './registerServiceWorker';
class Dynamic extends Component {
constructor(props) {
super(props);
this.state = { module: null };
}
@andybak
andybak / intercooler.html
Last active October 10, 2020 00:56
Example of adding Django CSRF token in an page that POSTs using intercooler.
{% extends "custom_base.html" %}
{% block content %}
<form id="defaults" >
<input name="csrfmiddlewaretoken" type="hidden" value="{{ csrf_token }}">
</form>
<table>
{% for row in items %}
@jbeluch
jbeluch / .screenrc
Created November 17, 2010 14:53
Basic .screenrc
startup_message off
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{..G}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a"
@jakub300
jakub300 / run.sh
Last active January 9, 2022 01:48
Compile headless shell (Chromium)
# Based on:
# https://web.archive.org/web/20200212121848/http://www.zackarychapple.guru/chrome/2016/08/24/chrome-headless.html
# https://www.chromium.org/developers/how-tos/get-the-code
# https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
apt-get update
apt-get install -y curl git htop man unzip vim wget python
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=$PATH:`pwd`/depot_tools
mkdir Chromium && cd Chromium
@border
border / long_polling.go
Created September 25, 2012 09:58
long polling for golang
package main
import (
"container/list"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
@RaviTezu
RaviTezu / installGO.sh
Last active May 13, 2022 16:25
Shell(bash) script to install golang on Linux and MacOS machines
#!/usr/bin/env bash
set -e
# Author: Ravi Teja Pothana (@RaviTezu)
# Date: Nov 15, 2016
# The MIT License (MIT)
# Copyright (c) 2016 RaviTezu