Skip to content

Instantly share code, notes, and snippets.

👨‍💻
At Office

Jagroop Singh jagroop

👨‍💻
At Office
View GitHub Profile
@shawnlindstrom
shawnlindstrom / TwilioServiceProvider.php
Created Jul 4, 2018
Twilio Service Provider for Laravel
View TwilioServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Twilio\Rest\Client as TwilioService;
class TwilioServiceProvider extends ServiceProvider
{
public function register()
@Atinux
Atinux / async-foreach.js
Last active Aug 6, 2020
JavaScript: async/await with forEach()
View async-foreach.js
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@fgilio
fgilio / axios-catch-error.js
Last active Aug 5, 2020
Catch request errors with Axios
View axios-catch-error.js
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@gabmontes
gabmontes / delete-all-my-gists.js
Last active Jun 3, 2020
Delete all your gists
View delete-all-my-gists.js
var async = require('async');
var GitHubApi = require('github');
var github = new GitHubApi({
version: '3.0.0',
protocol: 'https'
});
github.authenticate({
type: 'basic',
@PurpleBooth
PurpleBooth / README-Template.md
Last active Aug 6, 2020
A template to make good README.md
View README-Template.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@RuGa
RuGa / massInsertOrUpdate.php
Last active Jul 7, 2020
Mass (bulk) insert or update on duplicate for Laravel 4/5
View massInsertOrUpdate.php
/**
* Mass (bulk) insert or update on duplicate for Laravel 4/5
*
* insertOrUpdate([
* ['id'=>1,'value'=>10],
* ['id'=>2,'value'=>60]
* ]);
*
*
* @param array $rows
@adnan-i
adnan-i / mongoose-aggregate-by-month-year.js
Last active Jul 1, 2020
Mongoose aggregation for grouping users by month/year subscribed
View mongoose-aggregate-by-month-year.js
User.aggregate([
{
/* Filter out users who have not yet subscribed */
$match: {
/* "joined" is an ISODate field */
'subscription.joined': {$ne: null}
}
},
{
/* group by year and month of the subscription event */
@dennysfredericci
dennysfredericci / search-ul-li-item.js
Created Jul 22, 2014
A simple jquery code to search a text inside of li tag
View search-ul-li-item.js
//searchText is a input type text
$('#searchText').bind('keyup', function() {
var searchString = $(this).val();
$("ul li").each(function(index, value) {
currentName = $(value).text()
if( currentName.toUpperCase().indexOf(searchString.toUpperCase()) > -1) {
@FrostyX
FrostyX / FacebookDebugger.php
Last active May 20, 2020
Facebook API - Force facebook to reload cache from your website
View FacebookDebugger.php
<?php
class FacebookDebugger
{
/*
* https://developers.facebook.com/docs/opengraph/using-objects
*
* Updating Objects
*
* When an action is published, or a Like button pointing to the object clicked,
* Facebook will 'scrape' the HTML page of the object and read the meta tags.
@thomasfr
thomasfr / Git push deployment in 7 easy steps.md
Last active Aug 6, 2020
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
View Git push deployment in 7 easy steps.md
You can’t perform that action at this time.