Skip to content

Instantly share code, notes, and snippets.

View gormus's full-sized avatar
💭
Never be cruel, never be cowardly.

Osman Gormus gormus

💭
Never be cruel, never be cowardly.
View GitHub Profile
@gormus
gormus / index.html
Created April 23, 2015 06:47
Simple Map // source http://jsbin.com/nabexu
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
initialize: ->
@bind 'all', @_trackPageview
_trackPageview: ->
url = Backbone.history.getFragment()
_gaq.push(['_trackPageview', "/#{url}"])
@gormus
gormus / jquery-csrf.js
Last active August 29, 2015 14:26 — forked from vorushin/jquery-csrf.js
Small jQuery plugin for adding csrf-token to Ajax/Ajaj requests
$.ajaxSetup({
beforeSend: function(xhr, settings) {
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
@gormus
gormus / gist:8bae683acb53237fd770
Created October 22, 2015 19:27 — forked from clnmcgrw/gist:9086505
Google Maps API Geocode Example - PHP/JSON
<?php
// address to map
$map_address = "";
$url = "http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=".urlencode($map_address);
$lat_long = get_object_vars(json_decode(file_get_contents($url)));
// pick out what we need (lat,lng)
$lat_long = $lat_long['results'][0]->geometry->location->lat . "," . $lat_long['results'][0]->geometry->location->lng;
@gormus
gormus / guid.php
Created December 28, 2015 20:58
Create a GUID.
<?php
$guid = getGUID(array('{','}'));
print $guid;
function getGUID($strip = array()) {
$guid = '';
if (function_exists('com_create_guid')) {
$guid = com_create_guid();
@gormus
gormus / Gruntfile.js
Created January 16, 2016 03:11 — forked from matt-bailey/Gruntfile.js
This is the example Gruntfile that goes with my tutorial on front-end flat builds and automation: http://www.gpmd.co.uk/blog/front-end-process-flat-builds-and-automation-part-3-grunt-tasks/
// Generated on 2013-06-04 using generator-webapp 0.1.7
'use strict';
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
@gormus
gormus / Change Drupal installation profile.md
Created February 9, 2016 20:38
Change Drupal installation profile
$ drush vset install_profile standard

$ drush rr
$ drush cc all

$ drush sqlq "DELETE FROM `system` WHERE filename LIKE 'profiles/pantheon/pantheon.profile'"
$ drush sqlq "UPDATE `system` SET status=1 WHERE filename LIKE 'profiles/standard/standard.profile'"
@gormus
gormus / controller.php
Created April 23, 2016 04:40 — forked from tscheepers/GeoSpatialThingController.php
Geospatial sort by distance using Laravel 4 and MySQL. I'm using a point column named geolocation in a table called meetings.
<?php
class MeetingsController extends \BaseController {
/**
* Display a listing of the resource.
* GET /meetings
*
* @return Response
*/
@gormus
gormus / unset_by_value.php
Created June 16, 2016 03:33
Unset an item from an array by its value.
<?php
/**
* Unset an item from an array by its value.
*/
function unset_byvalue(array $array = array(), $value = '') {
$index = array_search($value, $array, TRUE);
if ($index !== FALSE) {
unset($array[$index]);
}
@gormus
gormus / template.php
Created June 22, 2016 20:41
Improve taxonomy term add/edit form in Drupal 7.x
<?php
/**
* Implements hook_form_FORM_ID_alter().
*/
function abc_form_taxonomy_form_term_alter(&$form, &$form_state) {
// Move all fieldsets into vertical-tabs.
$form['additional_settings'] = array(
'#type' => 'vertical_tabs',
);