Skip to content

Instantly share code, notes, and snippets.

View saubi1993's full-sized avatar
🎯
Focusing

saurabh kushwaha saubi1993

🎯
Focusing
  • Berlin, Germany
View GitHub Profile
@Bijendra
Bijendra / upload-images-s3-sdk-ruby
Last active May 30, 2023 08:20
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.
@oinopion
oinopion / read-access.sql
Created October 5, 2016 13:00
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@rogeruiz
rogeruiz / vim-everywhere-or-how-i-abstracted-away-my-workflow-and-cant-use-regular-computers-anymore.markdown
Last active September 10, 2021 19:36
18F Tech Talk Lite! 2017: How to Vim Everywhere. Or, how I abstracted away my workflow and can't use regular computers anymore

Preface

Hey there folks, I'm Roger and I use the terminal for just about everything text related. I really like using a keyboard over a mouse.

Let's begin our journey into my workflow with two things in mind. First off, there is very little research here in terms of actual productivity gains. I did this mostly for fun.

This is just how one person decided to hit the dopamine part of their brain

@rahulrajaram
rahulrajaram / .md
Last active April 2, 2023 15:47
Python: Write to a file from multiple threads

I recently came across the need to spawn multiple threads, each of which needs to write to the same file. Since the file will experience contention from multiple resources, we need to guarantee thread-safety.

NOTE: The following examples work with Python 3.x. To execute the following programs using Python 2.7, please replace threading.get_ident() with thread.get_ident(). As a result, you would need to import thread and not threading.

  1. (The following example will take a very long time). It will create 200 threads, each of which will wait until a global lock is available for acquisition.
# threading_lock.py
import threading