Skip to content

Instantly share code, notes, and snippets.

View harshalbhakta's full-sized avatar

Harshal Bhakta harshalbhakta

View GitHub Profile
@harshalbhakta
harshalbhakta / faraday_upload_to_s3_using_presinged_url.rb
Created December 14, 2021 18:18
Faraday upload to S3 using Presigned URL
require 'faraday'
# Amazon S3 presinged url
url = "https://<bucket-name>.s3.amazonaws.com/path-to-file/1.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAZTZBLMH3LBZ3WP5M%2F20211214%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211214T170722Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=d5929354744cb5d20102d92496c3b9e24a71dfd75535f4eee371979c2636f473"
response = Faraday.new(url).put("/path-to-file/1.txt") do |req|
req.body = File.binread("/Users/harshal/Temp/Trash/6.txt")
end
puts response.body
@harshalbhakta
harshalbhakta / code.swift
Created February 22, 2021 06:53
iOS Device Details
let currentDevice = UIDevice.current
print("name: \(currentDevice.name)")
print("systemName: \(currentDevice.systemName)")
print("systemVersion: \(currentDevice.systemVersion)")
print("model: \(currentDevice.model)")
print("localizedModel: \(currentDevice.localizedModel)")
print("userInterfaceIdiom: \(currentDevice.userInterfaceIdiom.rawValue)")
if let identifierForVendor = currentDevice.identifierForVendor {
print("identifierForVendor: \(identifierForVendor)")
@harshalbhakta
harshalbhakta / build.txt
Created February 22, 2021 06:02
Android Device Details
# Output 1
Build.BOARD : msm8953
Build.BOOTLOADER : 0xC212
Build.BRAND : motorola
Build.SUPPORTED_ABIS (Needs > LOLLIPOP) : [Ljava.lang.String;@da140ec
Build.DEVICE: sanders_n
Build.DISPLAY : OPS28.65-36-14
Build.FINGERPRINT : motorola/sanders_n/sanders_n:8.1.0/OPS28.65-36-14/63857:user/release-keys
Build.HARDWARE : qcom
@harshalbhakta
harshalbhakta / output.txt
Last active December 19, 2020 02:44
Eager load polymorphic in Rails 6.0.0
D, [2020-12-19T08:12:50.286546 #61072] DEBUG -- : (0.0ms) begin transaction
D, [2020-12-19T08:12:50.286771 #61072] DEBUG -- : User Create (0.1ms) INSERT INTO "users" ("name") VALUES (?) [["name", "First"]]
D, [2020-12-19T08:12:50.286964 #61072] DEBUG -- : (0.0ms) commit transaction
D, [2020-12-19T08:12:50.287390 #61072] DEBUG -- : (0.0ms) begin transaction
D, [2020-12-19T08:12:50.287502 #61072] DEBUG -- : User Create (0.0ms) INSERT INTO "users" ("name") VALUES (?) [["name", "Second"]]
D, [2020-12-19T08:12:50.287612 #61072] DEBUG -- : (0.0ms) commit transaction
D, [2020-12-19T08:12:50.287852 #61072] DEBUG -- : (0.0ms) begin transaction
D, [2020-12-19T08:12:50.287956 #61072] DEBUG -- : User Create (0.0ms) INSERT INTO "users" ("name") VALUES (?) [["name", "Third"]]
D, [2020-12-19T08:12:50.288063 #61072] DEBUG -- : (0.0ms) commit transaction
D, [2020-12-19T08:12:50.290632 #61072] DEBUG -- : (0.0ms) begin transaction
@harshalbhakta
harshalbhakta / DisplayProductID-717
Created October 20, 2020 11:28
DisplayVendorID-756e6b6e -> DisplayProductID-717
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>DisplayProductID</key>
<integer>1815</integer>
<key>DisplayVendorID</key>
<integer>1970170734</integer>
<key>tinf</key>
<dict>
@harshalbhakta
harshalbhakta / kotlin_apply.kt
Created October 15, 2020 10:11
Kotlin Apply
// before
binding.nicknameText.text = binding.nicknameEdit.text
binding.nicknameEdit.visibility = View.GONE
binding.doneButton.visibility = View.GONE
binding.nicknameText.visibility = View.VISIBLE
// after
binding.apply {
nicknameText.text = nicknameEdit.text.toString()
nicknameEdit.visibility = View.GONE
@harshalbhakta
harshalbhakta / .bash_logout
Created October 1, 2020 07:15
Default .bashrc, .profile and .bash_logout for Ubuntu 20.04.1 LTS (Non root user - /home/deployer/.bashrc)
# ~/.bash_logout: executed by bash(1) when login shell exits.
# when leaving the console clear the screen to increase privacy
if [ "$SHLVL" = 1 ]; then
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi
@harshalbhakta
harshalbhakta / youTube-api-v3-video-details.json
Created September 29, 2020 05:39
Youtube API v3 Video Details
{
"kind": "youtube#videoListResponse",
"etag": "ulocFefetbr7j8hsb7PP6JJlGUw",
"items": [
{
"kind": "youtube#video",
"etag": "SAxWY45YrAno4X9baF1UxgQGFbQ",
"id": "Ks-_Mh1QhMc",
"snippet": {
"publishedAt": "2012-10-01T15:27:35Z",
@harshalbhakta
harshalbhakta / ansible-playbook-example.yml
Last active September 26, 2020 15:55
Ansible Cheatsheet
---
- hosts: all
become: true
vars:
package: vim # Deifines a global variables that can be used across the playbook
packages: [ 'vim', 'git', 'curl' ] # Stor array in a variable
doc_root: /var/www/example
tasks:
# Installing a single package
- name: Install a single Package
@harshalbhakta
harshalbhakta / bash.md
Last active April 24, 2020 08:31
Installing libffi6 on Ubuntu 12.04
  $ sudo apt-get update
  $ sudo apt-get install libffi6