Skip to content

Instantly share code, notes, and snippets.

View kuldipem's full-sized avatar
:shipit:
Looking for new challenges

KULDIP PIPALIYA kuldipem

:shipit:
Looking for new challenges
View GitHub Profile
@kuldipem
kuldipem / app-exit.js
Created July 12, 2016 19:36
Cordova/PhoneGap exit app after twice press back button with toast ( plugin required https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin )
var lastTimeBackPress=0;
var timePeriodToExit=2000;
function onBackKeyDown(e){
e.preventDefault();
e.stopPropagation();
if(new Date().getTime() - lastTimeBackPress < timePeriodToExit){
navigator.app.exitApp();
}else{
window.plugins.toast.showWithOptions(
@kuldipem
kuldipem / angularjs-interceptor.js
Created July 12, 2016 19:34 — forked from gnomeontherun/angularjs-interceptor.js
Intercept XHR/Ajax requests with AngularJS http interceptors. This allows you to globally intercept and modify requests and responses. You don't need to declare all of the methods, just the ones you need. Some example uses would be logging errors, adding extra headers, or triggering 'loading' screens. This intercepts ALL requests/responses, so y…
// Intercepting HTTP calls with AngularJS.
angular.module('MyApp', [])
.config(function ($provide, $httpProvider) {
// Intercept http calls.
$provide.factory('MyHttpInterceptor', function ($q) {
return {
// On request success
request: function (config) {
// console.log(config); // Contains the data about the request before it is sent.
@kuldipem
kuldipem / .htaccess
Created July 12, 2016 06:50 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@kuldipem
kuldipem / jquery.alterclass.js
Created April 5, 2016 09:20 — forked from peteboere/jquery.alterclass.js
jQuery alterClass plugin: Remove element classes with wildcard matching. Optionally add classes.
/**
* jQuery alterClass plugin
*
* Remove element classes with wildcard matching. Optionally add classes:
* $( '#foo' ).alterClass( 'foo-* bar-*', 'foobar' )
*
* Copyright (c) 2011 Pete Boere (the-echoplex.net)
* Free under terms of the MIT license: http://www.opensource.org/licenses/mit-license.php
*
*/
@kuldipem
kuldipem / SassMeister-input.scss
Created November 27, 2015 19:56
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
$colors: #800080, #ff0000, #dc143c, #ff4500, #ff0000,#ffa500,#ff4500,
#ffd700,#ffa500,#9acd32,#ffd700,#008000,#9acd32,#4682b4,#87ceeb,#9370db,
#4682b4,#800080,#9370db;
$max: length($colors);
$dash: 10;
@kuldipem
kuldipem / iloveyou.c
Created July 21, 2015 14:44
Want to impress your girlfriend/boyfriend by your coding skill ?
/*
* File: main.c
* Author: KULDIP PIPALIYA <kuldipem@gmail.com>
*
* Created on 17 July, 2015, 10:17 AM
*/
#include <stdio.h>
#include <stdlib.h>
<?php
namespace Kem\CoreBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
find . -type f -iname '*.pdf'

#Introduction If you're a php developer on ubuntu, there comes the time where you have to install/reinstall your system. I did it already a few times and i decided to write down the steps for a typical web developer stack with php. This is for a developer machine and not for a live environment!

I hope it helps you too!

fyi @mheiniger and me started with an installer here: https://github.com/mheiniger/webdev-setup

@kuldipem
kuldipem / util-functions
Last active August 29, 2015 14:22
get unique values within range
<?php
function getUniqeValueWithinRang($count=10,$min=0,$max=10){
$uniqValuesInRange=[];
for($j=0;$j<$count;$j++){
$ran=rand($min,$max);
while(in_array($ran=rand($min,$max), $uniqValuesInRange));
array_push($uniqValuesInRange, $ran);
}
return $uniqValuesInRange;