Skip to content

Instantly share code, notes, and snippets.

@renz45
renz45 / replacement.js
Last active August 29, 2015 14:22
I came up to a problem the other day where I had to do a sort of token replacement in html without removing/recompiling the html nodes. I was working in angular, so data attached to html nodes needed to be preserved in this process. Below is my initial attempt, which seems to work at a glance.
<div id="test-el">
<div>some testing text blah</div>
<div>some testing <span>%replace%test span</span> text blah</div>
<p>something %replace% something blah</p>
</div>
<div id="control">
<div>some testing text blah</div>
<div>some testing <span>%replace%test span</span> text blah</div>
<p>something %replace% something blah</p>
CS.csVideoPLayer = {
speeds: [1, 1.5, 2, 2.5, 3],
init: function() {
var videos = $('.cs-video_player');
var el;
for(var i=0, l=videos.length; i < l; i++) {
el = videos[i];
CS.csVideoPLayer.initSublime(el);
CS.csVideoPLayer.initWrapper(el);
}
@renz45
renz45 / CombatMouseLock.ahk
Last active August 29, 2015 14:06
Autohotkey script that changes wildstar controls to be like tera (asian action rpg style)
;;; CombatMouseLock
;;; v1
;;; 9/6/2014
;;;
;;; Combat mouse lock attempts to recreate a jrpg style of play
;;; comparable to the game Tera. This differs from combing plugins
;;; like steer and mousebindings in that we don't get the clunkiness
;;; of rebinding the mouse buttons, so objects remain selectable
;;; without triggering the bound abilities. The windows key is used
;;; to enguage the lock, while pressing left alt will temporairy
@renz45
renz45 / toolTip.coffee
Created June 17, 2014 14:14
An example of wrapping the Twitter Bootstrap tooltip function in a directive to be used within an angular project. Note the `scope.$on '$destroy'` part that cleans up the tooltip and prevents memory leaks.
angular.module('myApp').directive 'tooltip', ->
restrict: 'A'
scope: {}
link: (scope, element, attrs)->
$(element).tooltip({
animation: attrs.animation
html: attrs.html
placement: attrs.placement
selector: attrs.selector
title: attrs.title
@renz45
renz45 / .file
Created February 27, 2014 13:03
atom, command line file/directory open
alias atom="open -a /Applications/atom.app"
class User < ActiveRecord::Base
def welcome
send_welcome_email(self)
enable_welcome_tour(self)
enable_welcome_promotion(self)
end
private
def send_welcome_email(user)
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, input, textarea, p, blockquote, th, td {
margin: 0;
padding: 0;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
fieldset, img {
border: 0;
let(:user) { Factory :user }
let!(:plan) { Factory :subscription_plan, code: HallPass::PLAN_CODE, price: 0 }
let!(:hall_pass) { Factory(:inactive_hall_pass) }
it 'should' do
..do something
end
@renz45
renz45 / error.sh
Created October 4, 2012 12:47
nodjitsu error
arduino_socket_server git:(master) ✗ jitsu deploy
info: Welcome to Nodejitsu renz45
info: jitsu v0.9.8
info: It worked if it ends with Nodejitsu ok
info: Executing command deploy
info: Analyzing application dependencies in app.js
error: Error running command deploy
error: UNABLE_TO_VERIFY_LEAF_SIGNATURE
error: Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE
error: at SecurePair.<anonymous> (tls.js:1312:32)
@renz45
renz45 / gist:3424757
Created August 22, 2012 11:47
Complete exercises for a user
u = User.find(123)
# complete all exercises in level 1
Exercise.all.each {|e| u.user_exercises.find_or_create_by_exercise_id(e.id).complete! if e.lab_id < 2 }