Skip to content

Instantly share code, notes, and snippets.

@mujsdev
mujsdev / Button.tsx
Created December 11, 2022 06:45
Button.tsx for Storybook
import React from "react";
export interface ButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
children: React.ReactNode;
color: "black" | "white";
size?: "sm";
hasBorder?: boolean;
disabled?: boolean;
isLoading?: boolean;
}
@OliverBalfour
OliverBalfour / README.md
Last active May 22, 2024 04:45
Obsidian custom checkbox snippet

Custom checkboxes for Obsidian! It's like deathau's snippet except updated to work really well in Live Preview mode in Obsidian 1.0.

Simply edit the x inside checkboxes to >, ?, etc. to see styling like below!

Editing Live Preview Viewing
image image image

Installation:

  • Download the checkbox.css file on this page
@titpetric
titpetric / client.lua
Created March 10, 2017 10:37
LUA FFI bridge to Go shared Lib
local ffi = require("ffi")
local awesome = ffi.load("./awesome.so")
ffi.cdef([[
typedef long long GoInt64;
typedef unsigned long long GoUint64;
typedef GoInt64 GoInt;
typedef GoUint64 GoUint;
typedef double GoFloat64;
@ssledz
ssledz / bash-cheat-sheet
Created May 21, 2016 14:36
BASH Cheat Sheet
B A S H C H E A T S H E E T
to page output forward (only): command filename | more
to page output forward & back: command filename | less
to print a dataset: lp datasetname (-d printerid) (-o landscape)
USE OF QUOTATION MARKS
echo "$varname" = echo The value of \$varname is \"$varname\"
= echo "The value of \$varname is \"$varname\"."
$fred='Four spaces between these words.'
@Rooster212
Rooster212 / elementsFromPoint.js
Last active February 10, 2021 11:51 — forked from oslego/elementsFromPoint.js
Gets all elements below the specified point. Checks to see if browser already has method before using a manual method. Originally found https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/dTYbg4_S2b8/bEtoAnkP0swJ
// returns a list of all elements under the cursor
//
function elementsFromPoint(x,y) {
var elements = [], previousPointerEvents = [], current, i, d;
if(typeof document.elementsFromPoint === "function")
return document.elementsFromPoint(x,y);
if(typeof document.msElementsFromPoint === "function")
return document.msElementsFromPoint(x,y);
var Col = require('react-bootstrap/lib/Col')
var PageHeader = require('react-bootstrap/lib/PageHeader')
var React = require('react')
var Row = require('react-bootstrap/lib/Row')
var {connect} = require('react-redux')
var {reduxForm} = require('redux-form')
var DateInput = require('./DateInput')
var FormField = require('./FormField')
var LoadingButton = require('./LoadingButton')
@miohtama
miohtama / rollingwindow.py
Last active January 15, 2022 21:20
Rolling window rate limitation implementation for Pyramid
"""Rolling time window counter and rate limit using Redis.
Use Redis sorted sets to do a rolling time window counters and limiters. These are useful for preventing denial of service, flood and reputation attack against site elements which trigegr outgoing action (email, SMS).
Example how to do a Colander validator which checks that the form has not been submitted too many times within the time period::
import colander as s
@c.deferred
def throttle_invites_validator(node, kw):
@paulirish
paulirish / what-forces-layout.md
Last active May 31, 2024 22:37
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@mbirtwell
mbirtwell / gist:aaccdb7972e1a7ed094b
Last active December 21, 2017 17:53
SQLAlchemy Enum recipe enhanced for use in postgresql arrays
# Based on http://techspot.zzzeek.org/2011/01/14/the-enum-recipe/
import six
from sqlalchemy.dialects import postgresql
from sqlalchemy.types import SchemaType, TypeDecorator, Enum
from sqlalchemy import __version__, text, cast
import re
if __version__ < '0.6.5':
raise NotImplementedError("Version 0.6.5 or higher of SQLAlchemy is required.")