Skip to content

Instantly share code, notes, and snippets.

View fokosun's full-sized avatar
:octocat:
I may be slow to respond.

fokosun fokosun

:octocat:
I may be slow to respond.
View GitHub Profile
@fokosun
fokosun / e2e-tests.yml
Created July 28, 2023 03:06 — forked from stfsy/e2e-tests.yml
Simple opinionated GitHub Actions workflow for end-to-end testing of Vue.js with TailwindCSS
name: e2e-tests
on: push
jobs:
build:
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
@fokosun
fokosun / index.js
Created January 11, 2023 19:45 — forked from ismailbaskin/index.js
GCP Pub/Sub to Slack message Cloud Function
const https = require('https');
const url = require('url');
const slackWebhookURL = 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX'; // CHANGE ME PLZ!
exports.gceAudit = (event, callback) => {
const msg = JSON.parse(Buffer.from(event.data.data, 'base64').toString());
const slackRequest = https.request({
hostname: url.parse(slackWebhookURL).hostname,
method: 'POST',
@fokosun
fokosun / ThrottleRequests.php
Created December 10, 2020 20:38 — forked from developerdino/ThrottleRequests.php
Lumen Middleware for rate limiting - based on Laravel's implementation.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Response;
use Illuminate\Cache\RateLimiter;
class ThrottleRequests
{
@fokosun
fokosun / php-calling-class-test.php
Created July 9, 2019 15:25 — forked from hamstar/php-calling-class-test.php
A function that will return the calling class to the class using it
/***********************************************************
******* SIMPLE TEST **/
class A {
function t() {
echo get_calling_class();
}
}
class B {
@fokosun
fokosun / index.php
Created October 25, 2018 12:42 — forked from mchelen/index.php
php check multidimensional array for duplicate values
<?php
$arrays = array(
array(
'name'=>'foo',
),
array(
'name'=>'bar',
),
array(
'name'=>'foo',
@fokosun
fokosun / StatusRepository.php
Created May 19, 2018 15:11 — forked from laracasts/StatusRepository.php
Integration Testing Repositories That Use Eloquent (with Codeception)
<?php namespace Larabook\Statuses;
use Larabook\Users\User;
class StatusRepository {
/**
* Get all statuses associated with a user.
*
* @param User $user
@fokosun
fokosun / instagram_scrape.php
Created April 21, 2016 17:25 — forked from cosmocatalano/instagram_scrape.php
Quick-and-dirty Instagram web scrape, just in case you don't think you should have to make your users log in to deliver them public photos.
<?php
//returns a big old hunk of JSON from a non-private IG account page.
function scrape_insta($username) {
$insta_source = file_get_contents('http://instagram.com/'.$username);
$shards = explode('window._sharedData = ', $insta_source);
$insta_json = explode(';</script>', $shards[1]);
$insta_array = json_decode($insta_json[0], TRUE);
return $insta_array;
}
@fokosun
fokosun / gist:ede2986a2912010ec8fff429b94ca3f2
Created April 18, 2016 15:44 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

<div class="tweet original-tweet js-stream-tweet js-actionable-tweet js-profile-popup-actionable js-original-tweet
" data-feedback-key="stream_status_374123416800206848" data-tweet-id="374123416800206848" data-item-id="374123416800206848" data-screen-name="dboudreau" data-name="Denis Boudreau " data-user-id="10096552" data-is-reply-to="true" data-has-parent-tweet="true" data-expanded-footer="&lt;div class=&quot;js-tweet-details-fixer tweet-details-fixer&quot;&gt;
&lt;div class=&quot;js-tweet-media-container &quot;&gt;&lt;/div&gt;&lt;div class=&quot;entities-media-container &quot; style=&quot;min-height:0px&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;js-machine-translated-tweet-container&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;js-tweet-stats-container tweet-stats-container &quot;&gt;
&lt;/div&gt;&lt;div class=&quot;client-and-actions&quot;&gt;
&lt;span class=&quot;metadata&quot;&gt;
&lt;span title=&quot;11:55 AM - 1 Sep 13&quot;&gt;11:55 AM - 1 Sep 13&lt;/span&gt;
&amp;middot; &lt;a class=&quot;permalink-lin