Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Azeirah
Azeirah / keybase.md
Created August 26, 2015 22:29
keybase.md

Keybase proof

I hereby claim:

  • I am azeirah on github.
  • I am azeirah (https://keybase.io/azeirah) on keybase.
  • I have a public key whose fingerprint is C6CC 3CFF 9C23 0D36 124F 26C2 B4D2 59A9 2CA3 1AE3

To claim this, I am signing this object:

@Azeirah
Azeirah / jQuery toggler
Last active August 29, 2015 13:56
jQuery toggler plugin.
(function ($) {
$.fn.toggler = function () {
var prefix = "data-az",
toggle_groups = $(document).find("[" + prefix + "-toggle-group]"),
togglable_groups = $(document).find("[" + prefix + "-togglable-group]"),
togglables = togglable_groups.find("[" + prefix + "-togglable]"),
toggles = toggle_groups.find("[" + prefix + "-toggle]");
togglables.hide();
@Azeirah
Azeirah / Web toolbelt.md
Last active August 29, 2015 14:01
Javascript simple utilities script that I use often.

A simple web toolbelt

Over time, I commonly see myself using certain functions over and over again, I rewrite them for a lot of applications I create. So instead of having to rewrite them every time, I collect them in this gist.

JavaScript utility Functions

toType

function init () {
instr(parseInt('0000110000', 2));
instr(parseInt('0000110000', 2));
instr(parseInt('0000110000', 2));
instr(parseInt('0000111000', 2));
instr(parseInt('0000001000', 2));
instr(parseInt('0000000001', 2));
instr(parseInt('0000000100', 2));
instr(parseInt('0000001111', 2));
}
@Azeirah
Azeirah / performance.md
Created July 10, 2014 05:13
JavaScript performance crap
var a = "bla";
for (var i = 0; i < 500000; i++) {
  a += "bla";
}

Is a little faster than

@Azeirah
Azeirah / gist:e14ca60b891b54639279
Created August 28, 2014 15:06
Failing async tests at creating two accounts
Tinytest.addAsync('test', function (test, done) {
if (Meteor.isClient) {
Accounts.createUser({
username: 'user1',
password: 'fruit'
}, function (err) {
Accounts.logout(function () {
Accounts.createUser({
username: 'user2',
password: 'fruit'
@Azeirah
Azeirah / gist.js
Last active August 29, 2015 14:05
OnCreateUser doesn't get called
if (Meteor.isServer) {
var _onCreateUser = Accounts.onCreateUser.bind(Accounts);
// Since onCreateUser overrides default behavior, and we don't want to restrict package users
// by removing the onCreateUser function, we override onCreateUser to modify the user document before the regular onCreateUser call.
Accounts.onCreateUser = function (func) {
console.log('oncreatinguser outer');
_onCreateUser(function (options, user) {
console.log('oncreateuser inner');
if (!user.profile) {
user.profile = options.profile || {};
@Azeirah
Azeirah / g.js
Created August 30, 2014 14:47
adding to profile
Template.register.events({
'submit #register-form': function(event, t) {
event.preventDefault();
var email = t.find('#register-email').value.toLowerCase();
var password = t.find('#register-password').value;
var username = t.find('#register-username').value;
Accounts.createUser({
email: email,
password: password,
username: username,
@Azeirah
Azeirah / meteorhelper.js
Created September 20, 2014 12:15
meteor helper
Template.previewNote.rerender = function () {
console.log(UI._templateInstance());
var codes = UI._templateInstance().findAll("pre>code");
for (var i = 0; i < codes.length; i++) {
hljs.highlightBlock(codes[i]);
}
};
@Azeirah
Azeirah / Instructions.md
Created March 25, 2016 17:27
Sublime Text - Automatic reindentation while swapping

Sublime Text has a somewhat hidden feature to automatically reindent the current line. It would be wasteful to bind this to a keybinding, I prefer it to be automatic.

print("Executing a function")
def someFunction():
    return 5

Moving the print line one line down with ctrl+shift+down will result in