Skip to content

Instantly share code, notes, and snippets.

@aaronshaf
aaronshaf / bookmarklet-expanded.js
Last active May 13, 2024 14:35
Copy text from Amazon's Cloud Reader. Helpful for students that need block quotes.
javascript: (function () {
new_window = window.open();
new_window.document.body.innerHTML = $("iframe")
.contents()
.find("iframe")
.contents()
.find("body")
.get(1).innerHTML;
new_window.document.body.querySelector("#content-overlays").remove();
})();
@orlando
orlando / cheap_downloader.rb
Created January 3, 2012 16:39
destroyallsoftware cheap screencast downloader
#!/usr/bin/ruby
require 'rss'
#this assumes you have a cookies.txt with destroyallsoftware.com cookies... later ill add a signin method..
class Link
attr_accessor :link,:title,:date
def initialize(link,title,date)
@link = link
@progrium
progrium / gist:5734609
Last active October 14, 2019 07:15
Let unprivileged processes easily restart/reload Nginx without sudo or setuid hacks
# run this as root
while [ 1 ]; do echo | nc -l -U /tmp/reload_nginx && /etc/init.d/nginx reload; done
# or as an upstart job
script
echo | nc -l -U /tmp/reload_nginx && /etc/init.d/nginx reload
end script
respawn
# now any process can run this or do the equivalent with sockets to trigger reload
@winebarrel
winebarrel / kinesis_client.rb
Created December 22, 2013 10:29
Kinesis Client
require 'json'
require 'openssl'
require 'net/http'
require 'net/https'
require 'time'
require 'stringio'
require 'zlib'
module Kinesis
class Client
@koulmomo
koulmomo / sublime_text_2_perfect_key_bindings
Created January 13, 2014 08:41
Perfect Sublime Text 2 Key Bindings. Tab to skip out of brackets, braces, parentheses, and quotes/quotations but still be able to indent
[
// Move out of common paired characters () and [] with `Tab`
{
"keys": ["tab"],
"command": "move",
"args": {"by": "characters", "forward": true},
"context": [
// Check if next char matches (followed by anything)
{ "key": "following_text", "operator": "regex_match", "operand": "(:?`|\\)|\\]|\\}).*", "match_all": true },
// ...and that there is a paid character before it on the same
@alexhawkins
alexhawkins / nativeJavaScript.js
Last active July 27, 2024 04:48
Implementation of Native JavaScript Methods (forEach, Map, Filter, Reduce, Every, Some)
'use strict';
/*****************NATIVE forEACH*********************/
Array.prototype.myEach = function(callback) {
for (var i = 0; i < this.length; i++)
callback(this[i], i, this);
};
//tests
@pulkitsinghal
pulkitsinghal / 01_chat.md
Last active November 28, 2016 03:36 — forked from doublemarked/1:middleware.json
Bunyan Loopback logging
doublemarked 09:50
@pulkitsinghal here’s a gist of the core of it all:
https://gist.github.com/doublemarked/e4bf329d11c55baf468f

@pulkitsinghal this will log access tokens with all log messages.
Bunyan produces JSON, so you’re essentially going to need to parse
the log to fish out things, but JSON makes it easy to do that.

For simple things (like access tokens) you can also use grep
@RickWong
RickWong / react.html
Last active April 20, 2021 15:48
Write React apps in 1 HTML file.
<html>
<body>
<div id="react-root"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-with-addons.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.5.2/redux.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.7.7/babel.min.js"></script>
<script id="react-app" type="text/template">
const App = ({name}) => {
@njohnson7
njohnson7 / snippet_of_vkbeautify.2.0.js
Created May 18, 2017 18:19
How to change indentation of Postman HTML Pretty view to 2 spaces instead of 4
function vkbeautify(){ // line 83 of vkbeautify.2.0.js
// change the string below to 2 spaces instead of 4:
this.step = ' '; // 4 spaces
this.shift = createShiftArr(this.step);
};