Skip to content

Instantly share code, notes, and snippets.

View toklok's full-sized avatar
💭
Permanent 418 status

Joseph Curtis toklok

💭
Permanent 418 status
View GitHub Profile
@dannyockilson
dannyockilson / gist:52a444195f0df873cc1c
Created March 13, 2015 17:11
Simple Angular Service for WordPress
'use strict';
angular.module('wordpress', [])
.service( 'wpService',
function($http, $q){
var url = 'http://allin.local/wp-json/';
return({
app.run([
function() {
/**
* Cause a full page load on every route change.
*/
$rootScope.$on('$locationChangeStart', function($event, changeTo, changeFrom) {
if (changeTo == changeFrom) {
return;
}
@lelandrichardson
lelandrichardson / ko-convenience.js
Created March 5, 2014 01:11
Knockout.js Custom Utility Bindings
(function (ko, handlers, unwrap, extend) {
"use strict";
extend(handlers, {
href: {
update: function (element, valueAccessor) {
handlers.attr.update(element, function () {
return { href: valueAccessor() };
});
}
},
@mweststrate
mweststrate / observe.js
Last active July 16, 2016 14:49
Object.observe is dead. Long live Mobservable.observe
// JSBin: http://jsbin.com/kekoli/edit?js,console
import {observable, observe} from "mobx";
const person = observable({
firstName: "Maarten",
lastName: "Luther"
});
const disposer = observe(person, (change) => {
console.log(`${change.type} '${change.name}' from '${change.oldValue}' to '${change.object[change.name]}'`);
@leoherzog
leoherzog / * set-up.md
Last active April 9, 2017 00:05
A quick-'n-dirty jQuery way of changing an HTML div contents based on if you are currently free or busy in Google Calendar
  • Make sure you are sharing at least free/busy details about your calendar to the public
  • Add freebusy.js and jQuery (with ajax support, not jQuery slim) to your project
  • Make an API Key at the Google Developers Console and enable Google Calendar support
  • Change the API key at line 5
  • Change the Google Calendar address from googlecalendarid@gmail.com to the one that you want to check on line 6
  • ???
  • Profit
@kdzwinel
kdzwinel / ps4devtools.js
Created October 8, 2017 21:31
Gamepad - Chrome DevTools integration
(function(){
let gamepad = null;
let loopInterval = null;
window.addEventListener("gamepadconnected", connectHandler);
window.addEventListener("gamepaddisconnected", disconnectHandler);
function connectHandler(e) {
if (!gamepad) {
@codef0rmer
codef0rmer / angular-jqueryui-dnd.html
Last active February 22, 2018 10:23
AngularJS + jQueryUI Drag & Drop
<!DOCTYPE html>
<html ng-app="App">
<head>
<meta name="description" content="AngularJS + jQuery UI Drag-n-Drop" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.0.1/angular.min.js"></script>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/css/bootstrap.min.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<meta charset=utf-8 />
Something like this:
+----------+ +-----------+
| |+----SSH+-->| |
| A | | B |
|+--------+| | |
Internet <-++-+PROXY<++<SSH Tunnel--+ |
|+--------+| | |
+----------+ +-----------+
@anvaka
anvaka / modules.md
Last active January 16, 2019 14:45
npm modules with highest pagerank

This excercise computes PageRank of npm dependencies graph.

  1. Download all npm modules: wget https://skimdb.npmjs.com/registry/_design/scratch/_view/byField
  2. Convert them into ngraph.graph using convertToGraph.js script.
  3. Run rank.js (see below):

Number of nodes: 123,969; Number of edges: 281,471; PageRank computed in 1,187 ms;

  1. underscore - 0.0132458168541106
  2. lodash - 0.012808245947189859
Failed attempts by username:
grep "Invalid user " /var/log/auth.log | cut -d' ' -f8 | awk '{a[$0]++}END{for(i in a)print i,a[i]}' | sort -k 2 -n -r | head -n 100
IP address of each attempt:
grep "Invalid user " /var/log/auth.log | cut -d' ' -f10 | awk '{a[$0]++}END{for(i in a)print i,a[i]}' | sort -k 2 -n -r | head -n 100
Filter for brute-force interactive SSH logins:
grep sshd.\*Failed /var/log/auth.log | less
Look for failed connections (i.e. no login attempted, could be a port scanner, etc.):