Skip to content

Instantly share code, notes, and snippets.

View ocReaper's full-sized avatar

Ákos Resch ocReaper

View GitHub Profile
@ocReaper
ocReaper / smoothscroll.js
Last active March 1, 2016 22:33
Anchor smooth scrolling via jQuery
APP.initAnchorScroll = function () {
var anchorScroll = function (hash, event) {
var headerHeight = $('.\\@header').find('.bar').outerHeight()
, $target = $(hash);
if (hash === '') {
return;
}
$target = $target.length ? $target : $('a[name=' + hash.slice(1) + ']');
@ocReaper
ocReaper / gist:5bc68467fc874a179c2d
Last active December 18, 2015 22:20
Blob file download in Angular.js using $resource Part 1
(function () {
'use strict';
angular
.module('app')
.factory('Email', Email);
function Email($resource) {
var url = 'emails/'
, EmailBase;
@ocReaper
ocReaper / gist:b320f6e67dbeabd27b89
Created December 18, 2015 22:21
Blob file download in Angular.js using $resource Part 2
/* global Blob */
(function () {
'use strict';
angular
.module('app')
.factory('Email', Email);
function Email($resource) {
@ocReaper
ocReaper / gist:29a9706b541b4d2443d3
Last active December 18, 2015 22:34
Blob file download in Angular.js using $resource Part 3
/* global URL */
(function () {
'use strict';
angular
.module('app')
.controller('EmailCtrl', EmailCtrl);
function EmailCtrl($scope, Email) {
@ocReaper
ocReaper / gist:2da6bcb418dbdbe55b81
Created December 18, 2015 22:34
Blob file download in Angular.js using $resource Part 4
<a target="_self" download="some.xlsx" ng-href="{{email.getUploadedFileUrl()}}">
Download
</a>
@ocReaper
ocReaper / gist:e7674c49c77ac9e2845c
Created December 18, 2015 22:36
Blob file download in Angular.js using $resource Part 5
(function () {
'use strict';
angular
.module('app')
.config(allowBlobLinkHrefs);
function allowBlobLinkHrefs($compileProvider) {
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|tel|file|blob):/);
}
@ocReaper
ocReaper / gist:d1c9df3d62079024a35a
Last active December 18, 2015 22:50
Blob file download in Angular.js using $resource Full
<!doctype html>
<html lang="en" data-ng-app='app' data-ng-controller="EmailCtrl as email">
<head>
<meta charset="UTF-8">
<title>Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.min.js"></script>
<script>
(function () {
'use strict';
@ocReaper
ocReaper / sample.js
Last active January 27, 2016 07:44
How to promisify ui-router state changes
// create the deferred variable
var stateChanged = $q.defer();
// hook our functionality to its promise
stateChanged
.promise
.then(function () {
// scroll to the desired element via ngSmoothScroll
var element = document.getElementById(next);
smoothScroll(element);
@ocReaper
ocReaper / .htaccess
Created March 1, 2016 10:52
Revoke 404 error handling from WordPress and passing to Apache simple
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(jpg|jpeg|png|gif|ico|swf|bmp)$ - [nocase,redirect=404,last]
@ocReaper
ocReaper / .htaccess
Created March 1, 2016 10:58
Revoke 404 error handling from WP and passing to Apache extended
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(css|js|html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|swf|tar|tif|tiff|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$ - [nocase,redirect=404,last]