Skip to content

Instantly share code, notes, and snippets.

View shivamanhar's full-sized avatar

Shiva Manhar shivamanhar

View GitHub Profile
#set the intensity of the halo
intensity = 250.0
#create a noramlizing constant so the halo fully fades out at the corners
denominator = intensity/((n/2)**2 + (m/2)**2)
#get the normalized squared distances of each pixel from the center
squared_distances = ((x-center_x)**2 + (y-center_y)**2)*denominator
#reshape this 2D matrix into a 3D matrix
@shivamanhar
shivamanhar / apn-server.php
Created August 14, 2017 13:00 — forked from samvermette/apn-server.php
Quickly send an Apple Push Notification using PHP
<?php
$apnsHost = 'gateway.sandbox.push.apple.com';
$apnsCert = 'apns-dev.pem';
$apnsPort = 2195;
$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', $apnsCert);
$apns = stream_socket_client('ssl://' . $apnsHost . ':' . $apnsPort, $error, $errorString, 2, STREAM_CLIENT_CONNECT, $streamContext);
@shivamanhar
shivamanhar / Layouts.php
Created November 16, 2015 15:08 — forked from queiroz/Layouts.php
CodeIgniter alternative layouts Library
<?php
class Layouts
{
// hold codeigniter instance
private $CI;
// hold layout title
private $layout_title = null;
@shivamanhar
shivamanhar / introrx.md
Last active August 29, 2015 14:25 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.