Skip to content

Instantly share code, notes, and snippets.

View sashadev-sky's full-sized avatar

sashadev-sky

  • New York, NY
View GitHub Profile
@sashadev-sky
sashadev-sky / vgoget.sh
Created August 4, 2023 07:07 — forked from rogpeppe/vgoget.sh
go get binary@version
#!/bin/sh
# This command installs binaries at specified versions
# into $GOBIN, $GOPATH/bin or $HOME/bin.
# It assumes Go 1.11.
if [ $# = 0 ]; then
usage: vgoget cmdpackage[@version]... >&2
exit 2
fi
d=`mktemp -d`
cd "$d"
@sashadev-sky
sashadev-sky / setup-vagrant-macosx.md
Created June 10, 2021 16:11 — forked from tomysmile/setup-vagrant-macosx.md
How to Install Virtualbox and Vagrant on MacOSX

Install Virtualbox && Vagrant for MacOSX

Vagrant uses Virtualbox to manage the virtual dependencies. You can directly download virtualbox and install or use homebrew for it.

$ brew cask install virtualbox

Now install Vagrant either from the website or use homebrew for installing it.

@sashadev-sky
sashadev-sky / README.md
Created May 15, 2021 05:17 — forked from Tynael/README.md
How to use npx to run gist based scripts
@sashadev-sky
sashadev-sky / blueprint.py
Created March 31, 2021 16:46 — forked from brenj/blueprint.py
Store application configuration in a Flask blueprint.
@blueprint.record_once
def record_params(state):
"""Store app.config in blueprint when blueprint is registered on app."""
app = state.app
blueprint.config = {key: value for key, value in app.config.iteritems()}
@sashadev-sky
sashadev-sky / render_json.py
Created March 27, 2021 05:01 — forked from nerevar/render_json.py
Pretty print json in jupyter/ipython notebook
import json
import uuid
from IPython.display import display_javascript, display_html, display
class RenderJSON(object):
def __init__(self, json_data):
if isinstance(json_data, dict) or isinstance(json_data, list):
self.json_str = json.dumps(json_data)
else:
self.json_str = json_data
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "rails"
@sashadev-sky
sashadev-sky / download.rb
Created June 3, 2020 17:15 — forked from robertjwhitney/download.rb
simple script to download an array of images over http
require 'net/http'
require 'yaml'
files = YAML.load_file("image_list.yml")
i = 1
files.each do |file|
# use root url without protocol
response = Net::HTTP.start("farm5.static.flickr.com") do |http|
http.get("#{file}")
end
puts "#{response}"
@sashadev-sky
sashadev-sky / if_while_assignment.md
Created June 3, 2020 17:12
One of these things is not like the other.

"if" statement assignment:

x = 0
y = if x == 0
  puts "test"
  'pizza'
end

# test
@sashadev-sky
sashadev-sky / annotate_image.rb
Created May 20, 2020 16:57 — forked from kamui/annotate_image.rb
Annotate text that auto fits within an image and benchmark on both graphicsmagick and imagemagick. Uses mini_magick
#!/usr/bin/env ruby
# Convert command line
#
#gm convert -font helvetica -fill white -pointsize 20 -draw "text 500,600 'WALLPAPERZ ARE GOOD'" test.jpg output.jpg
#
#convert -background transparent -fill white -gravity center -size 1024x200 -font Helvetica -pointsize 20 #caption:"I'm a wallpaper, you know what to do" test.jpg +swap -gravity south -composite output.jpg
#
# Mogrify command line
#
@sashadev-sky
sashadev-sky / upload-images-s3-sdk-ruby
Created May 7, 2020 03:54 — forked from Bijendra/upload-images-s3-sdk-ruby
Upload images to AWS S3 in rails application using aws-sdk
Using gem aws-sdk for a ror application for uploading images to s3
Uploading images to a fixed bucket with different folders for each object or application.
The s3 keeps a limitation on the number of buckets creattion whereas there is no
limitation for content inside a bucket.
This code will upload image for a user to s3 using aws-sdk gem. The bucket and the image uploaded are made public
so that the images uploaded are directly accessible. The input it takes is the image complete path
where it is present, folder in which it should be uploaded and user_id for whom it should
be uploaded.