Skip to content

Instantly share code, notes, and snippets.

View billyxs's full-sized avatar

Billy Montgomery billyxs

View GitHub Profile
@billyxs
billyxs / get-mouse-event-position.js
Last active August 29, 2015 14:02
Get Mouse Event Position
function(e) {
if(!e) var e = window.event;
var posx = 0;
var posy = 0;
if (e.pageX || e.pageY) {
posx = e.pageX;
posy = e.pageY;
}
@billyxs
billyxs / directive.onenter.js
Last active August 29, 2015 14:02
Angular - On Enter Keypress Directive
app.directive('xs-enter', function () {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
event.preventDefault();
if(event.which === 13) {
scope.$apply(function (){
scope.$eval(attrs.xsEnter);
});
}
});
@billyxs
billyxs / simulator-link.sh
Last active August 29, 2015 14:03
iPhone/iPad Simulator Link
@billyxs
billyxs / gist:25572da8cb6cb1fd143f
Last active August 29, 2015 14:06
iOS - Create dictionary from escaped JSON string
NSDictionary *data =
[NSJSONSerialization JSONObjectWithData: [@"{\"a\":\"A\", \"b\":\"B\"}" dataUsingEncoding:NSUTF8StringEncoding]
options: NSJSONReadingMutableContainers
error: nil];
@billyxs
billyxs / npm_globals_install_osx.sh
Last active April 19, 2018 18:30
Install NPM global modules for OSX
#!/bin/ssh
# message colors
GREEN='\033[0;32m'
CYAN='\033[0;36m'
NONE='\033[0m'
# npm it
# Install Dev Tools - Express, React, Bower, Nodemon, Node Inspector
@billyxs
billyxs / osx_brew_cask_installs.sh
Last active April 29, 2018 05:44
Install Homebrew, Cask, and necessary apps for Mac OSX
#!/bin/sh
echo Install Homebrew, Postgres, wget and cask
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Development
brew install node
brew install go
brew install dep # dep manager for go
brew install python3
@billyxs
billyxs / states.json
Last active September 17, 2015 21:44
United States with DC using abbreviation for id
[
{
"name": "Alabama",
"abbreviation": "AL",
"id": "AL"
},
{
"name": "Alaska",
"abbreviation": "AK",
"id": "AK"
@billyxs
billyxs / states_list_with_DC_object_literal.js
Last active October 13, 2015 17:46
Javascript list of 50 states with DC using object literal syntax
[
{
name: 'Alabama',
abbreviation: 'AL',
id: 'AL'
},
{
name: 'Alaska',
abbreviation: 'AK',
id: 'AK'
@billyxs
billyxs / crypto-pbkdf2-auth-example.js
Last active October 11, 2020 16:50
CryptoJS PBKDF2 hashing with javascript. This could be used for a simple, not high security, password auth.
// bower install crypto-js
// Add to scripts to html file
// <script src="bower_components/crypto-js/crypto-js.js"></script>
// <script src="bower_components/crypto-js/pbkdf2.js"></script>
function auth(password) {
// Make a salt with CryptoJS.lib.WordArray.random(128/8);
var salt = 'your salt'; // CryptoJS.lib.WordArray.random(128/8);
// 1000 iterations takes a couple seconds in the browser. Wouldn't want to go much higher if this is a browser implementation
@billyxs
billyxs / file_input_with_accessibility.html
Last active September 24, 2015 15:44
Styled file input button with accesibility
<!-- Solution as found in - http://tympanus.net/codrops/2015/09/15/styling-customizing-file-inputs-smart-way/ -->
<style>
.inputfile {
width: 0.1px;
height: 0.1px;
opacity: 0;
overflow: hidden;
position: absolute;
z-index: -1;