Skip to content

Instantly share code, notes, and snippets.

View mehrdad-shokri's full-sized avatar
🎯
Focusing

Mehrdad Shokri mehrdad-shokri

🎯
Focusing
View GitHub Profile
@mehrdad-shokri
mehrdad-shokri / business-models.md
Created November 3, 2016 07:13 — forked from ndarville/business-models.md
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@mehrdad-shokri
mehrdad-shokri / 0. intro.md
Last active April 8, 2018 02:44 — forked from jquense/0. intro.md
Alternative ways to define react Components

The 0.13.0 improvements to React Components are often framed as "es6 classes" but being able to use the new class syntax isn't really the big change. The main thing of note in 0.13 is that React Components are no longer special objects that need to be created using a specific method (createClass()). One of the benefits of this change is that you can use the es6 class syntax, but also tons of other patterns work as well!

Below are a few examples creating React components that all work as expected using a bunch of JS object creation patterns (https://github.com/getify/You-Dont-Know-JS/blob/master/this%20&%20object%20prototypes/ch4.md#mixins). All of the examples are of stateful components, and so need to delegate to React.Component for setState(), but if you have stateless components each patterns tends to get even simpler. The one major caveat with react components is that you need to assign props and context to the component instance otherwise the component will be static. The reason is

@mehrdad-shokri
mehrdad-shokri / gist:a0cf31223ae95c53240fa77ef654f906
Created July 28, 2017 03:55 — forked from tas50/gist:a072a027a63ffad752ee7b5199c95875
Update all global vagrant boxes (useful for test kitchen)
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Box type must be specified (virtualbox, vmware_desktop, parallels)"
exit 1
fi
# Find all boxes which have updates
AVAILABLE_UPDATES=`vagrant box outdated --global 2>/dev/null | grep outdated | tr -d "*'" | cut -d ' ' -f 2`
@mehrdad-shokri
mehrdad-shokri / SCSS.md
Created August 11, 2017 07:04 — forked from jareware/SCSS.md
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

@mehrdad-shokri
mehrdad-shokri / 1_README.md
Created October 23, 2017 10:33 — forked from Daniel15/1_README.md
Complete Google Drive File Picker example

Google Drive File Picker Example

This is an example of how to use the Google Drive file picker and Google Drive API to retrieve files from Google Drive using pure JavaScript. At the time of writing (14th July 2013), Google have good examples for using these two APIs separately, but no documentation on using them together.

Note that this is just sample code, designed to be concise to demonstrate the API. In a production environment, you should include more error handling.

See a demo at http://stuff.dan.cx/js/filepicker/google/

@mehrdad-shokri
mehrdad-shokri / Configure Keycloak Laravel
Created October 24, 2017 13:01 — forked from Bouhnosaure/Configure Keycloak Laravel
A way to use Keycloak as provider for login into laravel
This gist is created because the library i use eloquent-oauth-l5 has a pull-request (custom providers feature ) awaiting a merge
So here my way to use this feature and use keycloak as custom provider.
Inside composer.json
"repositories": [
{
"type": "vcs",
"url": "https://github.com/tysonlt/eloquent-oauth-l5"
}
@mehrdad-shokri
mehrdad-shokri / distance.sql
Created December 1, 2017 11:17 — forked from aramonc/distance.sql
MySQL function to calculate the distance between two coordinates using the Haversine formula. Leaving it here for future reference.
DELIMITER $$
CREATE FUNCTION `haversine` (lat1 DECIMAL(8,6), lng1 DECIMAL(8,6), lat2 DECIMAL(8,6), lng2 DECIMAL(8,6)) RETURNS DECIMAL(8,6)
BEGIN
DECLARE R INT;
DECLARE dLat DECIMAL(30,15);
DECLARE dLng DECIMAL(30,15);
DECLARE a1 DECIMAL(30,15);
DECLARE a2 DECIMAL(30,15);
DECLARE a DECIMAL(30,15);
DECLARE c DECIMAL(30,15);
@mehrdad-shokri
mehrdad-shokri / AppServiceProvider.php
Last active January 3, 2018 13:02
Laravel default string length limit
use Illuminate\Support\Facades\Schema;
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Schema::defaultStringLength(191);
@mehrdad-shokri
mehrdad-shokri / SagaManager.js
Created January 6, 2018 19:58 — forked from hoschi/SagaManager.js
Hot reloadable redux-saga ... sagas
import mySaga from 'mySaga';
import { take, fork, cancel } from 'redux-saga/effects';
const sagas = [mySaga];
export const CANCEL_SAGAS_HMR = 'CANCEL_SAGAS_HMR';
function createAbortableSaga (saga) {
if (process.env.NODE_ENV === 'development') {
return function* main () {