Skip to content

Instantly share code, notes, and snippets.

View tunecino's full-sized avatar
🏠
Working from home

Salem Ouerdani tunecino

🏠
Working from home
View GitHub Profile
@peterbsmyth
peterbsmyth / recipe.example.md
Last active May 21, 2020 13:39
Making chained API Calls using @ngrx/Effects

Making chained API Calls using @ngrx/Effects

Purpose

This recipe is useful for cooking up chained API calls as a result of a single action.

Description

In the below example, a single action called POST_REPO is dispatched and it's intention is to create a new repostiory on GitHub then update the README with new data after it is created.
For this to happen there are 4 API calls necessary to the GitHub API:

  1. POST a new repostiry
  2. GET the master branch of the new repository
  3. GET the files on the master branch
@jclosure
jclosure / contains_key_or_empty.txt
Created July 3, 2017 05:33
Kibana Painless scripted field checks if field exists or is empty and returns default, otherwise value
if (!doc.containsKey('myfield') || doc['myfield'].empty) { return "unavailable" } else { return doc['myfield'].value }
<?php
namespace app\models;
use yii\base\Model;
use Yii;
/**
* Simplified model with validation rules.
* All characters are allowed (you want emojis in the password? Go ahead).
@w00fz
w00fz / sphp.sh
Last active November 28, 2024 12:37
PHP switcher
#!/bin/bash
# Check if command was ran as root.
if [[ $(id -u) -eq 0 ]]; then
echo "The command \"sphp\" should not be executed as root or via sudo directly."
echo "When a service requires root access, you will be prompted for a password as needed."
exit 1
fi
# Usage
@btroncone
btroncone / ngrxintro.md
Last active March 5, 2025 20:40
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@staltz
staltz / introrx.md
Last active April 24, 2025 06:10
The introduction to Reactive Programming you've been missing
@ThomasBurleson
ThomasBurleson / AuthenticationModule.js
Created May 16, 2014 16:29
AngularJS SPA example of using a Session model with Authenticator service
/**
* AngularJS SPA Sample using Authenticator service with Session model
*
* @author Thomas Burleson
*
*/
(function( angular ){
"use strict";
/**
@Melros
Melros / tinymce-4-email-plugin.js
Last active November 27, 2018 20:21
This plugin will insert a mailto: link by providing an email address within tinymce 4.
/*
1. Create a folder named "email" within "tinymce/plugins".
2. Create a file called "plugin.min.js" within the folder.
2. Paste the below code inside "tinymce/plugins/email/plugin.min.js"
3. Extend your tiny.init like:
tinymce.init({
plugins: "email",
toolbar: "email"
@karlgroves
karlgroves / gist:7545632
Created November 19, 2013 13:49
PHP function to get the MIME type of a remote file.
function getRemoteMimeType($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
# get the content type
return curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
}
@6174
6174 / Random-string
Created July 23, 2013 13:36
Generate a random string in JavaScript In a short and fast way!
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);