Skip to content

Instantly share code, notes, and snippets.

View skopp's full-sized avatar

Rashaad Essop skopp

View GitHub Profile
//create the menu itens
chrome.contextMenus.create({
"title": "Cache: Last Hour",
"onclick": function () {
clear("Cache", 1000 * 60 * 60)
}
});
chrome.contextMenus.create({
"title": "Cache: Last Day",
"onclick": function () {
HTMLTextAreaElement.prototype.getCaretPosition = function () { //return the caret position of the textarea
return this.selectionStart;
};
HTMLTextAreaElement.prototype.setCaretPosition = function (position) { //change the caret position of the textarea
this.selectionStart = position;
this.selectionEnd = position;
this.focus();
};
HTMLTextAreaElement.prototype.hasSelection = function () { //if the textarea has selection then return true
if (this.selectionStart == this.selectionEnd) {
javascript: (function(document) {
window.open('data:text/html;charset=utf-8,' + encodeURIComponent('
<!doctype html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" type="text/css" rel="stylesheet" />
<style>
pre.prettyprint { padding: 0; border: none; }
</style>
<script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript"></script>
@main-font-size: 16px;
.x-rem (@property, @value) {
// This is a workaround, inspired by https://github.com/borodean/less-properties
@px-fallback: @value * @main-font-size;
-: ~`(function () { return ';@{property}: @{px-fallback}'; }())`;
-: ~`(function () { return ';@{property}: @{value}rem'; }())`;
}

QUICK setup Github Pages + Cloud9 IDE for HTML/CSS/JavaScript hacking

GitHub + GitHub Pages

  1. Get a GitHub account: https://github.com/
  2. Github > Dashboard > New Repository ... https://github.com/repositories/new
  3. Enter a Project Name and Description; click "Create Repository"
  4. On the project page ignore the suggested setup instructions... instead click on the "Admin" button
  5. Check the "GitHub Pages" checkbox... You'll get a popup.
  6. Click the "Automatic GitHub page Generator" button.
  7. Choose a funky colour... or go safe with just white... then click "Create Page" button
@skopp
skopp / fake_s3_cmds.txt
Last active December 15, 2015 09:28 — forked from jubos/gist:2409369
ref: jubos/fake-s3
[default]
access_key = asf
bucket_location = US
cloudfront_host = cloudfront.amazonaws.com
cloudfront_resource = /2010-07-15/distribution
default_mime_type = binary/octet-stream
delete_removed = False
dry_run = False
encoding = UTF-8
encrypt = False

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@skopp
skopp / README.rst
Last active December 14, 2015 23:59 — forked from dupuy/README.rst
Markdown and REStructuredText syntax - MD / RST

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.

import os
import urllib2
import tarfile
import shutil
import traceback
# Downloads and installs the dateutil library into a directory called 'dateutil'
# alongside your saved Pythonista scripts.
# It also creates a directory called 'temp' during the installation process which
# is deleted after installation.
@skopp
skopp / gfm.rb
Created March 2, 2013 13:52 — forked from mojombo/gfm.rb
require 'digest/md5'
def gfm(text)
# Extract pre blocks
extractions = {}
text.gsub!(%r{<pre>.*?</pre>}m) do |match|
md5 = Digest::MD5.hexdigest(match)
extractions[md5] = match
"{gfm-extraction-#{md5}}"
end