Skip to content

Instantly share code, notes, and snippets.

@morsdyce
morsdyce / header.php
Created August 2, 2014 22:29
Sub pages menu on wordpress
<?php
if (isset($cat) && !empty($cat)) : ?>
<nav role="category-navigation">
<a href="#" id="dropdown-menu"><?php _e('Menu', 'dwframework'); ?></a>
<?php
@morsdyce
morsdyce / newFile1.txt
Created June 15, 2014 14:29 — forked from elentok/gist:3193556
Vim Hebrew edit mode
imap <f2> <c-o>:call ToggleHebrew()<cr>
map <f2> :call ToggleHebrew()<cr>
func! ToggleHebrew()
if &rl
set norl
set keymap=
else
set rl
set keymap=hebrew
@morsdyce
morsdyce / .vimrc
Created June 10, 2014 16:20 — forked from JeffreyWay/.vimrc
set nocompatible " Disable vi-compatibility
set t_Co=256
colorscheme xoria256
set guifont=menlo\ for\ powerline:h16
set guioptions-=T " Removes top toolbar
set guioptions-=r " Removes right hand scroll bar
set go-=L " Removes left hand scroll bar
set linespace=15
@morsdyce
morsdyce / 01.configure
Created May 13, 2014 21:38 — forked from sanusart/01.configure
gist with files more than 1M of size #big
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /usr/bin/clang accepts -g... yes
checking for /usr/bin/clang option to accept ISO C89... none needed
checking whether we are using the GNU C++ compiler... yes
checking whether /usr/bin/clang++ accepts -g... yes
@morsdyce
morsdyce / script.js
Created April 30, 2014 22:45
input[type="text"] toggle default value or empty #jquery
//// input[type="text"] toggle default value
$('input[type="text"]').blur(function() {
if (this.value == '') this.value = this.defaultValue;
});
$('input[type="text"]').focus(function() {
if (this.value == this.defaultValue) this.value = '';
});
@morsdyce
morsdyce / app.js
Created December 22, 2013 16:19
Wordpress style body classes in angular #angularjs #javascript
app.run(function ($rootScope) {
$rootScope.$on('$routeChangeSuccess', function (e, data) {
if (data.$$route && data.$$route.controller) {
$rootScope.controller = data.$$route.controller.toLowerCase().replace('controller', '-controller');
}
})
});
@morsdyce
morsdyce / formhandler.cs
Created December 16, 2013 16:11 — forked from anonymous/gist:5311068
Web Api Remove the need for [FromBody] and [FromURI] #asp.net #mvc #webapi
public class FormHandler : DelegatingHandler
{
protected override System.Threading.Tasks.Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
{
if (request.Content != null && request.Content.Headers.ContentType != null &&
request.Content.Headers.ContentType.MediaType == "application/x-www-form-urlencoded")
{
var routeData = request.Properties["MS_HttpRouteData"] as IHttpRouteData;
var form = request.Content.ReadAsFormDataAsync().Result;
@morsdyce
morsdyce / cors.php
Created September 16, 2013 09:55
PHP CORS request #php #cors #crossdomain
<?php
// Allow from any origin
if (isset($_SERVER['HTTP_ORIGIN'])) {
header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Max-Age: 86400'); // cache for 1 day
}
// Access-Control headers are received during OPTIONS requests
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
@morsdyce
morsdyce / exampleController.js
Created June 5, 2013 20:45
Usage of requestHandler #gisto #angular #website_embed
'use strict';
function exampleController($scope, requestHandler) {
// notifications are enabled by default, if you do not wish the notification
// to show provide the stopNotification property with the value true
requestHandler({
method: 'GET',
url: 'http://localhost/api/gist/1',
// stopNotification: true // will stop the notification from being displayed.
@morsdyce
morsdyce / byMultipleValues.js
Created May 29, 2013 14:45
Multiple value angular filter #angularjs #filter
'use strict';
var app = angular.module('vulcanApp');
app.filter('byMultipleValues', function() {
return function(data, params) {
if (params.length === 0) {
return data;
}
return data.filter(function(element, index) {