Skip to content

Instantly share code, notes, and snippets.

View mlynch's full-sized avatar
🍂
Building something new

Max Lynch mlynch

🍂
Building something new
View GitHub Profile
@mlynch
mlynch / app.plist
Last active January 27, 2019 21:38 — forked from mhartington/README.md
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
@mlynch
mlynch / gist:5a53aa2f6a997c386e02
Created November 18, 2014 05:55
v8flags issue
$ npm install -g gulp
/
> v8flags@1.0.3 install C:\Users\Max_2\AppData\Roaming\npm\node_modules\gulp\nod
e_modules\v8flags
> node fetch.js
-
C:\Users\Max_2\AppData\Roaming\npm\node_modules\gulp\node_modules\v8flags\fetch.
@mlynch
mlynch / drawer.js
Last active August 29, 2015 14:08
Menu and Drawer toggle
angular.module('myApp', ['ionic'])
.directive('menuAndDrawerClose', ['$ionicViewService', function($ionicViewService) {
return {
restrict: 'AC',
require: '?^ionSideMenus,?^drawer',
link: function($scope, $element, $attr, ctrls) {
$element.bind('click', function(){
ctrls[0] && ctrls[0].close();
ctrls[1] && ctrls[1].close();
angular.module('maxlynch')
/**
* A simple ace-editor widget for adding a rich code editor
* in place of a textarea with full ngModel support.
*
* Usage:
*
* <ace-editor language="javascript" theme="monokai"></ace-editor>
*
@mlynch
mlynch / autofocus.js
Last active August 24, 2022 15:03
AngularJS Autofocus directive
/**
* the HTML5 autofocus property can be finicky when it comes to dynamically loaded
* templates and such with AngularJS. Use this simple directive to
* tame this beast once and for all.
*
* Usage:
* <input type="text" autofocus>
*
* License: MIT
*/
@mlynch
mlynch / auth.markdown
Last active September 4, 2020 18:11
AngularJS Authentication and CORS

Single Page Apps are ruling the world and AngularJS is leading the charge. But many of the lessons we learned in the Web 2.0 era no longer apply, and few are as drastically different as authentication.

CORS

CORS is an oft-misunderstood feature of new browsers that is configured by a remote server. CORS stands for Cross-Origin-Resource-Sharing, and was designed to make it possible to access services outside of the current origin (or domain) of the current page.

Like many browser features, CORS works because we all agree that it works. So all major browsers like Chrome, Firefox, and IE support and enforce it. By using these browsers, you benefit from the security of CORS.

That means certain browsers do not enforce it, so it is not relevant there. One large example is a native Web View for things like Cordova and Phonegap. However, these tools often have configuration options for whitelisting domains so you can add some security that way.

@mlynch
mlynch / directive.markdown
Last active July 31, 2017 14:37
Making of an AngularJS Directive

A while back I made a quick AngularJS directive for Bootstrap 3 Tooltips. I wanted to be able to specify tooltips on any element like this:

<button title="Settings" data-placement="bottom" data-delay="500"
data-toggle="tooltip"><i class="icon ion-gear"></i></button>

But I wanted to be able to do it without having to call $([data-toggle="tooltip"]').tooltip() every time I loaded a new page with tooltips, which is what you'd have to do if you were using vanilla jQuery and Bootstrap without something like Angular.

I built a really simple directive that worked perfectly, and I realized this was a perfect example of creating a simple custom directive that makes your life so much easier.

@mlynch
mlynch / Undo.md
Last active April 9, 2024 11:28
Undo/Redo

Undo/Redo

Undo/Redo is one of those features of an application that you almost always need to have if you are building serious GUI tools for people to do work.

The best way to look at undo/redo is two stacks of operations the user has performed:

  • The Undo stack is the "history" of what they've done
  • The redo stack is the breadcrumbs back to the initial state before they started undoing
@mlynch
mlynch / test.js
Created August 18, 2014 19:07
post for mdata
$http({
method: 'POST',
url: apiUrl + '/signup',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
data: data,
transformRequest: function(obj) {
var str = [];
for( var p in obj )
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
return str.join("&");
@mlynch
mlynch / nav.js
Last active August 29, 2015 14:01
first idea for nav transition stuff
/**
* For each navigation controller on scope, we can have one child control animation during transitions
* by enabling overriding a function:
*/
controller('MyCtrl', function($scope, $ionicNavDelegate, $ionicAnimation)) {
var pushAnim = $ionicAnimation({
duration: 1,
curve: 'ease-in-out',