Skip to content

Instantly share code, notes, and snippets.

View avastamin's full-sized avatar

Ruhul Amin avastamin

View GitHub Profile
@avastamin
avastamin / gist:fcf434c457e70d651e3b7713a3879a1c
Created July 27, 2016 07:04 — forked from Mithrandir0x/gist:3639232
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
<?php
$file = 'file.csv';
$line = array();
$file = fopen($file,"r");
while(! feof($file))
{
$line = fgetcsv($file);
}
/*
* Function to create form shortcode
*/
function request_form_func($atts, $content = null){
extract(shortcode_atts(array(
'id' => false,
'class' => false,
'title' => false,
'subtitle' => false,
'action' => "/thanks",
@avastamin
avastamin / ajax_promise.js
Created March 13, 2017 10:06
Ajax with Promises
function generatListItems(employees) {
var statusHTML = '';
for (var i=0; i<employees.length; i += 1) {
if (employees[i].inoffice === true) {
statusHTML += '<li class="in">';
} else {
statusHTML += '<li class="out">';
}
statusHTML += employees[i].name;
statusHTML += '</li>';
@avastamin
avastamin / chain_design_pattern.php
Created April 26, 2017 07:42
Chain Design Pattern in PHP
<?php
abstract class HomeChecker {
protected $succeesor;
public abstract function check(HomeStatus $home);
public function succeedWith(HomeChecker $succeesor){
$this->succeesor = $succeesor;
/*
* Programming Quiz: Make An Iterable Object
*
* Turn the `james` object into an iterable object.
*
* Each call to iterator.next should log out an object with the following info:
* - key: the key from the `james` object
* - value: the value of the key from the `james` object
* - done: true or false if there are more keys/values
*
@avastamin
avastamin / pardot-form-handler-iframe.html
Created October 10, 2017 13:57 — forked from afischoff/pardot-form-handler-iframe.html
Example of using a hidden iframe to pass data to a Pardot form handler before continuing with normal form submission.
<html>
<head>
<title>Pardot Example Form Handler Submit</title>
<!-- Include jQuery -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- Post to Pardot function -->
<script type="text/javascript">
// set the pardot form handler url and form element id
@avastamin
avastamin / braking.md
Created December 11, 2017 08:50
Fahrschule
@avastamin
avastamin / IndexedDB101.js
Created January 7, 2018 18:09 — forked from JamesMessinger/IndexedDB101.js
Very Simple IndexedDB Example
// This works on all devices/browsers, and uses IndexedDBShim as a final fallback
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB;
// Open (or create) the database
var open = indexedDB.open("MyDatabase", 1);
// Create the schema
open.onupgradeneeded = function() {
var db = open.result;
var store = db.createObjectStore("MyObjectStore", {keyPath: "id"});
@avastamin
avastamin / README.md
Created February 15, 2018 12:22 — forked from hofmannsven/README.md
My simply Git Cheatsheet