Skip to content

Instantly share code, notes, and snippets.

View humanismusic's full-sized avatar
💭
Building

Humanismusic humanismusic

💭
Building
View GitHub Profile
def fragmention(self, bookmark):
# Normalize whitespace and encode text as UTF8
text = ' '.join(self.text.split()).encode('utf-8')
url_parts = urlparse(bookmark.url)
# If the URL has no path (i.e. http://google.com) add a "/" then append fragmention
formatter = '%s/##%s' if not len(url_parts.path) else '%s##%s'
fragmention_url = formatter % (url_parts.geturl(), urllib.quote_plus(text))
@emilbjorklund
emilbjorklund / breakpoints_via_css.html
Created April 24, 2012 16:03
Width detection via sneaky CSS rules
<!DOCTYPE html>
<!--[if IE 8]> <html lang="sv-SE" class="no-js ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="sv-SE" class="no-js"> <!--<![endif]-->
<head>
<meta charset="UTF-8">
<title>Breakpoint detection test</title>
<style type="text/css" media="screen">
@media screen and (min-width: 320px) {
#page:after {
content: 'smallest'; /* represent the current width-bracket */
@katowulf
katowulf / example_rules.js
Created February 10, 2016 00:25
A list of example patterns for security rules validations
{
"rules": {
// REQUIRED FIELDS
"example1" : {
"$record": {
// foo and bar are required fields that must always exist
// this will reject writes to $record, as well as directly to $record/foo or $record/bar if they are null
".validate": "newData.hasChildren(['foo', 'bar'])"
}
@katowulf
katowulf / controller.js
Last active April 12, 2017 14:12
Example of infinite scroll in Ionic with Firebase (utilizes Firebase.util.Scroll; http://firebase.github.io/firebase-util/)
var app = angular.module('myapp', ['ionic', 'firebase'])
app.controller('ctrl', function($scope, $firebaseArray) {
// create a connection to Firebase
var baseRef = new Firebase('https://webapi.firebaseio.com/rolodex');
// create a scrollable reference
var scrollRef = new Firebase.util.Scroll(baseRef, 'name');
// create a synchronized array on scope
@adamloving
adamloving / twitter-user-timeline.js
Created May 15, 2011 21:37
The simplest way to get a user's Twitter timeline using Javascript and jQuery
var url = "http://twitter.com/status/user_timeline/adamloving.json?count=10&callback=?";
$.getJSON( url, function( data ){ console.log(data) });
@treypeng
treypeng / main.js
Last active March 18, 2019 07:53
Script to detect darth maul candles from bitmex 1h interval data
require('./util');
const Candler = require('./candle-db');
const ATR_LENGTH = 24;
const SMA_LENGTH = 24;
let trs = []; // series. needed by atr() function.
@ErisDS
ErisDS / setup.md
Last active April 13, 2019 09:58
Setup steps for installing Ghost on a fresh Ubuntu 16.04 server

Variables:

<server_ip> - ip of the server the blog is being installed on - name for the server e.g. "myblog" - domain name e.g. "myblog.mycompany.com" <ghost_mysql_pw> - a password for a ghost user in mysql <ssl_email> - an email address for letsencrypt

Steps to get from Ubuntu 16.04 fresh install to Ghost

Largely based on the following:

@JackGJenkins
JackGJenkins / show_intercom_launcher_after_scroll_or_action.js
Last active August 22, 2019 16:51
Simple jQuery snippet to show the Intercom messenger launcher when your user scrolls to the bottom of the page, or clicks a button.
//SHOW THE LAUNCHER WHEN A USER SCROLLS TO THE BOTTOM OF YOUR PAGE
//You'll need to have 'hide_default_launcher: true' defined in your intercomSettings object when the page loads initially.
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
Intercom('update', {"hide_default_launcher": false});
}
});
//SHOW THE LAUNCHER AFTER A USER CLICKS A BUTTON
@hijonathan
hijonathan / readme.md
Last active September 16, 2019 11:43
Fun in-browser web scraper.

What is this?

This little script lets you easily define a few things you want from a web page (using CSS selectors), the crawl the site until you get them all.

It's based on the way Kimono works, but it's much simpler and has no limit to the number of results you can get. It also uses your auth tokens from the browser, so it's just as secure as your browser (which you should still be suspect of).

How do I use it?

Put that script into your browser terminal and run it. If you use Chrome, I highly recommend saving it as a snippet for easy reuse. To start scraping a site, create a Scraper instance with your desired options:

@katowulf
katowulf / rules.js
Created March 3, 2016 00:05
Search for users by email address in Firebase, without exposing everyone's email address to the world in a bulk-readable format.
{
"rules": {
"users": {
"$user_id": {
// email address is required
".validate": "newData.hasChildren(['email'])",
}
},
"emails_to_users": {