Skip to content

Instantly share code, notes, and snippets.

Working from home

Petar Bojinov pbojinov

Working from home
View GitHub Profile
pbojinov /
Last active Mar 2, 2021
Two way iframe communication- Check out working example here:

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.


Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')


pbojinov / jquery.deferred.promise.js
Last active Feb 28, 2021
simple jQuery Deferred example
View jquery.deferred.promise.js
function getData() {
var deferred = $.Deferred();
'url': '',
'success': function(data) {
'error': function(error) {


Use useState:

  1. if you manage JavaScript primitives as state
  2. if you have simple state transitions
  3. if you want to have business logic within your component
  4. if you have different properties that don’t change in any correlated manner and can be managed by multiple useState hooks
  5. if your state is co-located to your component
  6. if you’ve got a small application (but the lines are blurry here)
pbojinov / canada_states_titlecase.json
Last active Feb 18, 2021 — forked from mshafrir/states_hash.json
US states & Canadian Provinces in JSON form
View canada_states_titlecase.json
"name": "Alberta",
"abbreviation": "AB"
"name": "British Columbia",
"abbreviation": "BC"
View gist:9732278
SOPA Emergency IP list:
Here’s how to access your favorite sites in the event of a DNS takedown
# News

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

pbojinov / multipleDeferredAjax.js
Created Feb 19, 2014
Multiple Simultaneous Ajax Requests (with one callback) in jQuery
View multipleDeferredAjax.js
// Get the HTML
$.get("/feature/", function(html) {
globalStore.html = html;
// Get the CSS
$.get("/assets/feature.css", function(css) {
pbojinov / data-action.js
Last active Sep 4, 2020
manually bind an event listener for each value that data-action might hold -
View data-action.js
// Using [data-action=""] selectors instead of class selectors when binding events in JavaScript
var actions = {
action1: function() {},
action2: function() {}
$('body').on('click', '[data-action]', function() {
var action = $(this).data('action');
if (action in actions) {
pbojinov /
Created Jun 21, 2014
Here is how you can create a table, with indexes, using PynamoDB -
from pynamodb.models import Model
from pynamodb.indexes import GlobalSecondaryIndex, AllProjection
from pynamodb.attributes import UnicodeAttribute, NumberAttribute
class DaysIndex(GlobalSecondaryIndex):
This class represents a global secondary index
read_capacity_units = 2
import os
from PIL import Image, ImageDraw, ImageFont
# make sure you have the fonts locally in a fonts/ directory
georgia_bold = 'fonts/georgia_bold.ttf'
georgia_bold_italic = 'fonts/georgia_bold_italic.ttf'
# W, H = (1280, 720) # image size
W, H = (720, 405) # image size
txt = 'Hello Petar this is my test image' # text to render