Skip to content

Instantly share code, notes, and snippets.

View kalpesh-fulpagare's full-sized avatar
🎯
RubyOnRails, GoLang, AngularJS Developer

Kalpesh Fulpagare kalpesh-fulpagare

🎯
RubyOnRails, GoLang, AngularJS Developer
  • Scalefusion
  • Pune, India
View GitHub Profile
@kalpesh-fulpagare
kalpesh-fulpagare / rails-debug.rb
Last active March 20, 2024 13:13
Handy Commands for Rails Server Debugging
# Rails console - handy commands
#
ActiveRecord::Base.logger = Logger.new(STDOUT)
# Change log level to debug
Rails.logger.level = Logger::DEBUG
# Print the line & file from where SQL got triggerred
ActiveRecord::Base.verbose_query_logs = true
@kalpesh-fulpagare
kalpesh-fulpagare / File_rename.rb
Created July 5, 2020 06:36
Ruby Script to get timestamp from FIlename & rename the file to a common format
require 'time'
names = []
Dir.glob('*').select { |f| File.file?(f)}.each do |fn|
file_name = fn.gsub('_', '')
timestamp = Time.parse(file_name[file_name.index('20200'), 14])
ext = file_name.split(".").last.downcase
if ext == "mp4"
new_file_name = timestamp.strftime("VID%Y%m%d-%H%M%S")
else
adb shell pm disable-user --user 0 com.oppo.market # Can not be disabled
adb shell pm disable-user --user 0 com.google.ar.core
adb shell pm disable-user --user 0 com.nearme.browser
adb shell pm disable-user --user 0 com.oppo.qualityprotect
adb shell pm disable-user --user 0 com.google.android.apps.wellbeing
adb shell pm disable-user --user 0 com.facebook.system
adb shell pm disable-user --user 0 com.facebook.services
adb shell pm disable-user --user 0 com.colouros.gamespace # Failed
adb shell pm disable-user --user 0 com.google.android.googlequick # Failed
adb shell pm disable-user --user 0 com.android.providers.partnerbookmarks
@kalpesh-fulpagare
kalpesh-fulpagare / grep.sh
Last active August 26, 2019 09:07
Grep Search
# Find requests for a Device/API
LOGFILE="log/development.log"
OUTPUT=$(grep -an 'Started PUT "/api/v1/users/information' $LOGFILE | grep -o "........-....-....-....-............" | awk 'ORS="|"')
OUTPUT=${OUTPUT%?};
echo $OUTPUT
OUTPUT=$(egrep -an $OUTPUT $LOGFILE | grep 'userid => 15841' | grep -o "........-....-....-....-............" | awk 'ORS="|"')
OUTPUT=${OUTPUT%?};
echo $OUTPUT
egrep -an $OUTPUT $LOGFILE
{
"always_show_minimap_viewport": false,
"auto_complete": true,
"auto_complete_commit_on_tab": true,
"binary_file_patterns":
[
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
@kalpesh-fulpagare
kalpesh-fulpagare / file-joiner.sh
Last active December 27, 2018 07:27
Join Multiple Files from Linux Command Line
echo 'file-chunk'{1..19}'.ts' | tr " " "\n" > file_listing
cat file_listing
touch combined_test_file.ts
while read line; do cat $line >> combined_test_file.ts; done < file_listing
while read line; do rm -f $line; done < file_listing
rm -f file_listing
@kalpesh-fulpagare
kalpesh-fulpagare / mixins.scss
Last active September 6, 2016 14:57
Mixin for Generaing CSS classes for margin and padding.
/*
* Generate Margin/Padding Classes
* margin, margin-top, margin-bottom, margin-left, margin-right
* padding, padding-top, padding-bottom, padding-left, padding-right
*/
@mixin margin-padding($min, $max, $css-property, $klass, $csspx: $min) {
@while $min <= $max {
@if $min != 0 {
@kalpesh-fulpagare
kalpesh-fulpagare / heroku-db.csv
Created February 8, 2016 12:39
Heroku DB Table - Export CSV
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 30 in line 1.
heroku pg:psql --app APP_NAME
\copy (SELECT users.id, CONCAT(first_name, ' ', middle_name, ' ', last_name) AS full_name, username, dob, gender, address_line_1, address_line_2, province, zipcode, email, phone_number, minor, roles.name as role, avatar_url, email_frequency, sign_in_count, license_code, city, elise_points, used_points, contact_person, phone, website, chamber_of_commerce_no, notes FROM users LEFT JOIN roles on role_id=roles.id) TO users-8feb-2016.csv CSV HEADER DELIMITER ','
@kalpesh-fulpagare
kalpesh-fulpagare / PostgressCheatsheet.sql
Last active October 23, 2021 18:59
Postgres Useful commands.
sudo -u postgres psql -d template1 -c "CREATE USER kalpesh WITH PASSWORD 'password' CREATEDB;"
sudo -u postgres psql -d template1 -c "CREATE DATABASE sample_db OWNER kalpesh;"
sudo -u postgres psql -d template1 -c "CREATE USER kalpesh CREATEDB;"
sudo -u postgres -H psql -d template1
/* =========================== Users =========================== */
/* Create User with password */
CREATE USER kalpesh WITH PASSWORD 'kalpesh';
/* Drop User */
@kalpesh-fulpagare
kalpesh-fulpagare / image_preview.js
Last active August 29, 2015 14:11
Angular Directive to Show File Upload image thumbnail
angular.module('image-preview-demo',[]).directive('imgPreviewElem', [function () {
return {
restrict: 'AE',
link: function(scope, elem, attrs) {
console.log("directive called")
elem.bind('change', function () {
var file=elem[0].files[0],
imageType=/(image.jpeg|image.png|image.jpg)/,
imgElementId = attrs.imgPreviewElem;