Skip to content

Instantly share code, notes, and snippets.

View jonmaim's full-sized avatar
🌍
Back in Europe!

Jon Maim jonmaim

🌍
Back in Europe!
View GitHub Profile
@jonmaim
jonmaim / gist:666042
Created November 7, 2010 10:02
usr.sbin.mysqld
We couldn’t find that file to show.
@jonmaim
jonmaim / gist:805601
Created February 1, 2011 08:46
Git checkout every file with changed file properties (run it in root git dir).
$ git status --porcelain --untracked-files=no | awk '{if ($1 == "M") print;}' | cut -d " " -f 3-20 | awk '{gsub(/ /,"\\ ");print}' | xargs -L 1 git diff --summary | cut -d " " -f 7-20 | awk '{gsub(/ /,"\\ ");print}' | xargs -L 1 git checkout
@jonmaim
jonmaim / zip.php
Last active July 30, 2024 09:19
PHP script to remotely create zip archives of your FTP
<?php
/*
*
* This script will backup your web site by remotely archiving all files on the root FTP directory.
* It will work even if your web server is memory limited buy splitting zips in several arhive files it they are too many files.
* All zip files will be stored in a directory called temporary which must be writable.
*
* How to use it:
* - Place the script at the root of your FTP.
@jonmaim
jonmaim / unsecure_php_image_proxy.php
Created September 16, 2011 03:19
Really unsecure php image proxy.
<?php
$filename = $_GET['url'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
switch ($ext) {
case "gif":
header('Content-Type: image/gif');
readfile($filename);
break;
@jonmaim
jonmaim / qs.js
Created December 8, 2012 10:51
Generate query string for angular.js
/* Converts an object into a key/value par with an optional prefix. Used for converting objects to a query string */
var qs = function(obj, prefix){
var str = [];
for (var p in obj) {
var k = prefix ? prefix + "[" + p + "]" : p,
v = obj[k];
str.push(angular.isObject(v) ? qs(v, k) : (k) + "=" + encodeURIComponent(v));
}
return str.join("&");
}
@jonmaim
jonmaim / gist:7149430
Last active December 26, 2015 12:09
JS coding style guide made at Minsh collaboratively.

Coding Style For Javascript

"For us code is our poetry and its our privilege to make it beautiful and readable.”

Whitespaces

  • The basic indentation is two spaces.
  • Try to keep lines to 80 characters or less ```javascript var result = prompt(message, initialValue,
'use strict';
angular.module('cafeApp')
.directive('inspect', function($timeout, $http) {
Element.prototype.serializeWithStyles = (function () {
var defaultStylesByTagName = {};
var noStyleTags = {'BASE':true,'HEAD':true,'HTML':true,'META':true,'NOFRAME':true,'NOSCRIPT':true,'PARAM':true,'SCRIPT':true,'STYLE':true,'TITLE':true};
@jonmaim
jonmaim / gist:fe19a8077de115a8e1e6
Created August 12, 2014 16:15
Get number of Angular watchers in the page
(function () {
var root = angular.element(document.getElementsByTagName('body'));
var watchers = 0;
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
watchers += (element.data().$scope.$$watchers || []).length;
}
angular.forEach(element.children(), function (childElement) {
@jonmaim
jonmaim / index.html
Last active August 29, 2015 14:05
Angular lazy one-time binding playground
<html>
<head>
</head>
<script src="http://code.angularjs.org/1.3.0-beta.18/angular.js"></script>
<script>
var myApp = angular.module('myApp',[]);
myApp.controller('MyCtrl', function MyCtrl($scope) {
$scope.name = 'Superhero';
setTimeout(function() {
@jonmaim
jonmaim / twilio
Last active August 29, 2015 14:06
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial action="http://twimlets.com/simulring?Dial=true&amp;FailUrl=+http%3A%2F%2Ftwimlets.com%2Fvoicemail%3FEmail%3Dhello%2540minsh.net%26Message%3DMinsh%2520office%2520is%2520busy%2520right%2520now%252C%2520please%2520leave%2520a%2520message%2520and%2520we" timeout="30">
<Number url="http://twimlets.com/whisper?Message=press+any+key">917411718230</Number>
<Number url="http://twimlets.com/whisper?Message=press+any+key">918971927344</Number>
</Dial>
</Response>