Skip to content

Instantly share code, notes, and snippets.

@ripiuk
ripiuk / bitbucket-pipelines.yml
Created December 16, 2020 17:26
An example of bitbucket pipeline configuration to sync changed files with Google Cloud Storage
image: <your_image>
pipelines:
default:
- step:
name: <description>
deployment: <your_deployment_name>
image: google/cloud-sdk:320.0.0-alpine
script:
# on linux you can use `$ base64 -w 0 < ~/.google_app_credentials.json` to generate $GCP_KEY_FILE
@ripiuk
ripiuk / main.go
Created December 15, 2020 07:44
Fetch several web pages simultaneously, and print the URL of the biggest page (defined as the most bytes in the response)
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
type Page struct {
URL string
@ripiuk
ripiuk / google_hash_code_pizza_2020.py
Created February 1, 2020 17:40
Solution for the Practice Round of Google Hash Code 2020 - Score: 1,505,004,616
import sys
import time
from pathlib import Path
from functools import reduce
def get_previous_num(num, shift):
last_part = num & (1 << shift) - 1
first_part = num >> (shift * 2) << shift
return last_part + first_part
@ripiuk
ripiuk / introspector.py
Created October 14, 2019 10:41
Object Introspection Tool
import inspect
import itertools
import reprlib
from sorted_set import SortedSet
def full_sig(method):
try:
return method.__name__ + str(inspect.signature(method))
except ValueError:
@ripiuk
ripiuk / simple_rest.go
Created June 22, 2019 11:28
Simple REST app using golang
package main
import (
"encoding/json"
"github.com/gorilla/mux"
"log"
"math/rand"
"net/http"
"strconv"
)
@ripiuk
ripiuk / get_insta_images.py
Last active June 19, 2019 21:08
Get instagram images/videos of some user
import re
import os
import time
import uuid
import json
import asyncio
import typing as typ
import urllib.parse as urlparse
from argparse import ArgumentParser
@ripiuk
ripiuk / img_search_google.py
Last active June 8, 2019 17:47
search images in google and parse the html page
import os
import time
import uuid
import asyncio
import typing as typ
import urllib.parse as urlparse
from lxml import html
from aiohttp import ClientSession
@ripiuk
ripiuk / exercise-fibonacci-closure.go
Created January 30, 2019 09:11
go tour exercise (moretypes/26)
package main
import "fmt"
func fibonacci() func() int {
x1 := 0
x2 := 1
res := 0
return func() int {
res, x1, x2 = x1, x2, x1 + x2
@ripiuk
ripiuk / exercise-maps.go
Created January 30, 2019 09:09
go tour exercise (moretypes/23)
package main
import (
"golang.org/x/tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
count := make(map[string]int)
words := strings.Fields(s)
@ripiuk
ripiuk / exercise-stringers.go
Created January 29, 2019 20:48
go tour exercise (methods/18)
package main
import (
"fmt"
"strconv"
"strings"
)
type IPAddr [4]byte