Skip to content

Instantly share code, notes, and snippets.

Avatar

Abhinav Kulshreshtha Abhinav1217

View GitHub Profile
View laravel_virtualhost_nginx.conf
server {
listen 80;
server_name www.example.com;
root /var/www/vhosts/example.com/public/;
location /
{
index index.php index.html index.htm;
}
@Abhinav1217
Abhinav1217 / PHPMinify.php
Last active Aug 29, 2015
A simple php script to Minify PHP files in PHP project using PHP shell command in terminal..
View PHPMinify.php
<?php
/**
* @author Abhinav Kulshreshtha
* @version 1.0
* @copyright 2015-End_of_Time Abhinav Kulshreshtha
* @license DO WHAT THE F**K YOU WANT TO PUBLIC LICENSE < http://www.wtfpl.net/ >
*
* @todo Looks Like I missed managing symlinks.
*/
@Abhinav1217
Abhinav1217 / Demo: Selecting First Child.html
Last active Dec 14, 2015
# Demo for different methods of selecting the first child element
View Demo: Selecting First Child.html
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<title>Demo For first child item</title>
<style>
@Abhinav1217
Abhinav1217 / PHP: better_print_r.php
Last active Dec 15, 2015
A Better alternative to PHP print_r() function.
View PHP: better_print_r.php
<?php
/**
* This function is an alternative to default PHP print_r() function.
* it displays the output as a recursive list items with highlighted key and values.
*/
function pp($arr){
$retStr = '<ul>';
if (is_array($arr)){
foreach ($arr as $key=>$val){
if (is_array($val)){
@Abhinav1217
Abhinav1217 / stickyTitles.js
Created Dec 17, 2015 — forked from andrewlaskey/stickyTitles.js
Sticky Instagram-like Headers
View stickyTitles.js
//http://stackoverflow.com/questions/13279725/getting-a-sticky-header-to-push-up-like-in-instagrams-iphone-app-using-css-a
function stickyTitles(stickies) {
this.load = function() {
stickies.each(function(){
var thisSticky = jQuery(this).wrap('<div class="followWrap" />');
thisSticky.parent().height(thisSticky.outerHeight());
@Abhinav1217
Abhinav1217 / GetEnumValuesFromMySQL.php
Last active Dec 21, 2015
Get enum values from some column in Mysql/Mariadb with PHP or PDO
View GetEnumValuesFromMySQL.php
<?php
/** This snippet can be used as <options> in <SELECT> in html **/
?>
<select>
<?php
$result = mysql_query('SHOW COLUMNS FROM '.$table_name.' WHERE field="'.$column_name.'"');
while ($row = mysql_fetch_row($result)) {
foreach(explode("','",substr($row[1],6,-2)) as $option) {
print("<option>$option</option>");
View javascript: getWeek.js
/**
* Add a getWeek() method in Javascript inbuilt Date object.
* This function is the colsest I could find which is ISO-8601 compatible. This is what php's `Date->format('w')` uses.
* ISO-8601 means.
* Week starts from Monday.
* Week 1 is the week with first thurday of the year or the week which has 4th jan in it.
* @param {[Date]} Prototype binding with Date Object.
* @return {[Int]} Integer from 1 - 53 which denotes the week of the year.
*/
@Abhinav1217
Abhinav1217 / ..git-pr.md
Created Aug 25, 2018 — forked from gnarf/..git-pr.md
git pr - Global .gitconfig aliases for Pull Request Managment
View ..git-pr.md

Install

Either copy the aliases from the .gitconfig or run the commands in add-pr-alias.sh

Usage

Easily checkout local copies of pull requests from remotes:

  • git pr 4 - creates local branch pr/4 from the github upstream(if it exists) or origin remote and checks it out
  • git pr 4 someremote - creates local branch pr/4 from someremote remote and checks it out
@Abhinav1217
Abhinav1217 / certificate.sh
Created Dec 6, 2018 — forked from volkancakil/certificate.sh
A basic Self Signed SSL Certificate utility
View certificate.sh
#!/usr/bin/env bash
# A basic Self Signed SSL Certificate utility
# by Andrea Giammarchi @WebReflection
# https://www.webreflection.co.uk/blog/2015/08/08/bringing-ssl-to-your-private-network
# # to make it executable and use it
# $ chmod +x certificate
# $ ./certificate # to read the how-to
View dynamic-svg-image-placeholders.markdown

Dynamic SVG image placeholders

How it works

  1. Loads the Potrace Lib (6KB min+gzip)
  2. Starts loading the full res source image
  3. Meanwhile...
  4. Grabs a low res thumbnail from Cloudinary (~5KB)
  5. Uses Potrace to generate an svg from the thumbnail
  6. Colours and fades the SVG in as a crisp, full-size placeholder