Skip to content

Instantly share code, notes, and snippets.

View styfle's full-sized avatar

Steven styfle

View GitHub Profile
anonymous
anonymous / Search Current Site
Created April 4, 2011 02:53
A Bookmarklet that searches the current site using Google. -styfle
javascript:var%20u%20=%20document.URL;%20%20var%20a%20=%20u.split("://");%20var%20protocol%20=%20a[0];%20var%20temp%20=%20a[1];%20%20a%20=%20temp.split("/");%20var%20fullDomain%20=%20a[0];%20var%20theRest%20=%20a[1];%20%20var%20q%20=%20window.prompt("Search%20"+fullDomain+"%20for:%20","");%20q%20=%20q.replace("%20",%20"+");%20document.location%20=%20"http://www.google.com/search?btnG=1&pws=0&q=site%3A"+fullDomain+"+"+q;
@hidenorigoto
hidenorigoto / gist:981969
Created May 19, 2011 22:42 — forked from avalanche123/gist:981817
GitHub Emoji
:+1:
:-1:
:airplane:
:art:
:bear:
:beer:
:bike:
:bomb:
:book:
:bulb:
@pcardune
pcardune / .gitignore
Created September 5, 2011 04:55
Facebook command-line client helper
.fb_access_token
.fbconsole.py
let wasm;
const heap = new Array(32).fill(undefined);
heap.push(undefined, null, true, false);
function getObject(idx) { return heap[idx]; }
let heap_next = heap.length;
@themanifold
themanifold / node-prune.sh
Last active October 1, 2022 02:47
Pruning useless node_modules with bash userland tools (find etc)
#!/usr/bin/env bash
find node_modules \( -name '__tests__' -o \
-name 'test' -o \
-name 'tests' -o \
-name 'powered-test' -o \
-name 'docs' -o \
-name 'doc' -o \
-name '.idea' -o \
-name '.vscode' -o \
-name 'website' -o \
@dfkaye
dfkaye / js-get-fn-name.js
Last active October 31, 2022 11:44
get a javascript function name
function getFnName(fn) {
fn = Object(fn)
var F = typeof fn == 'function'
var N = fn.name
var S = F && ((N && ['', N]) || fn.toString().match(/function ([^\(]+)/))
return (!F && 'not a function') || (S && S[1] || 'anonymous');
}
console.log(getFnName(String)); // 'String'
console.log(getFnName(function test(){})); // 'test'
@bgrins
bgrins / Log-.md
Last active August 1, 2023 16:32
Prevent errors on console methods when no console present and expose a global 'log' function.

Javascript log Function

Every time I start a new project, I want to pull in a log function that allows the same functionality as the console.log, including the full functionality of the Console API.

There are a lot of ways to do this, but many are lacking. A common problem with wrapper functions is that the line number that shows up next to the log is the line number of the log function itself, not where log was invoked. There are also times where the arguments get logged in a way that isn't quite the same as the native function.

This is an attempt to once and for all document the function that I pull in to new projects. There are two different options:

  • The full version: Inspired by the plugin in HTML5 Boilerplate. Use this if you are writing an application and want to create a window.log function. Additionally,
@benkehoe
benkehoe / aws.opml
Last active November 20, 2023 20:32
AWS RSS feeds
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>AWS RSS feeds 2019-04-22</title>
</head>
<body>
<outline text="AWS" title="AWS">
<outline type="rss" text="Infrastructure &amp; Automation" title="Infrastructure &amp; Automation" xmlUrl="https://aws.amazon.com/blogs/infrastructure-and-automation/feed/" htmlUrl="https://aws.amazon.com/blogs/infrastructure-and-automation/"/>
<outline type="rss" text="AWS Developer Blog" title="AWS Developer Blog" xmlUrl="http://feeds.feedburner.com/AwsDeveloperBlog" htmlUrl="https://aws.amazon.com/blogs/developer/"/>
@nicolashery
nicolashery / elasticsearch.md
Last active December 30, 2023 19:03
Elasticsearch: updating the mappings and settings of an existing index

Elasticsearch: updating the mappings and settings of an existing index

Note: This was written using elasticsearch 0.9.

Elasticsearch will automatically create an index (with basic settings and mappings) for you if you post a first document:

$ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \
'{
  "_id": 1,
class Example extends React.Component<
Props,
State,
Snapshot
> {
static getDerivedStateFromProps(
nextProps: Props,
prevState: State
): $Shape<State> | null {
// ...