Skip to content

Instantly share code, notes, and snippets.

View rawnly's full-sized avatar
🧨
fixing my printer

Federico rawnly

🧨
fixing my printer
View GitHub Profile
@rawnly
rawnly / example.js
Last active November 8, 2018 18:34
Simple settings manager for nodejs apps
const Settings = require('./Settings').shared;
// or
const Settings = require('./Settings')('~/my-app-settings.json');
const { prompt } = require('inquirer');
(async () => {
const wait = delay => new Promise(resolve => setTimeout(() => resolve(), delay));
try {
@rawnly
rawnly / ig-zoom-1.swift
Last active May 17, 2019 11:19
Gist for the medium article
import Foundation
import UIKit
class ViewController: UIViewController {
// MARK: - UI Initialization
// The image that we will zoom/drag
var imageView = UIImageView()
// The dark overlay layer behind the image
/// Setup imageView
private func setupImageView() {
// Set the image
imageView.image = UIImage(named: "your-asset-name-here")
// Resize the content
imageView.contentMode = .scaleAspectFill
imageView.layer.masksToBounds = true
// ... ViewController
// Let's start
override func viewDidLoad() {
super.viewDidLoad()
// Do not forget to enable user interaction on our imageView
imageView.isUserInteractionEnabled = true
let pinch = UIPinchGestureRecognizer(target: self, action: #selector(handlePinchGesture))
extension ViewController: UIGestureRecognizerDelegate {
// that method make it works
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
@objc func handleZoom(_ gesture: UIPinchGestureRecognizer) {
switch gesture.state {
case .began, .changed:
import Foundation
import UIKit
class ViewController: UIViewController {
// MARK: - UI Initialization
// The image that we will zoom/drag
var imageView = UIImageView()
// The dark overlay layer behind the image
@rawnly
rawnly / amazon-scraper.py
Created January 3, 2019 16:55
Scrape an amazon product and save the data.
# -*- coding: utf-8 -*-
import re
from requests import session, get
from bs4 import BeautifulSoup
from contextlib import closing
from requests.exceptions import RequestException
from tinydb import TinyDB, Query
db = TinyDB("products.json")
//
// Settings.swift
// Stockpapers
//
// Created by Federico Vitale on 12/01/2019.
// Copyright © 2019 Federico Vitale. All rights reserved.
//
import Foundation
import UIKit
/*
* READ BEFORE COPY-PASTING THIS FILE
* - The following script is buggy
* - This will not work, it has been tested on May 14th 2019 and the server response is 403.
* - PR are welcome if someone has any workaround/solution.
*/
const fs = require("fs");
const fetch = require("isomorphic-fetch");
const path = require("path");