Skip to content

Instantly share code, notes, and snippets.

Unnikrishnan KP unnitallman

Block or report user

Report or block unnitallman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View create_postgres_database_and_user.md
sudo -u postgres psql
postgres=# create database mydb;
postgres=# create user myuser with encrypted password 'mypass';
postgres=# grant all privileges on database mydb to myuser;
@unnitallman
unnitallman / s3.markdown
Created Jun 26, 2018 — forked from greenantdotcom/s3.markdown
Setting public read-only ACL for uploaded files
View s3.markdown

Alternatively, in the Amazon interface, you can select a directory or file, and click on the action "Mark as public"

@unnitallman
unnitallman / assets.rake
Created Feb 8, 2017 — forked from Geesu/assets.rake
Disable asset precompilation on heroku
View assets.rake
Rake::Task["assets:precompile"].clear
namespace :assets do
task 'precompile' do
puts "Not pre-compiling assets..."
end
end
@unnitallman
unnitallman / README.md
Created Mar 12, 2015 — forked from oodavid/README.md
Mysql to S3 backup
View README.md

Backup MySQL to Amazon S3

This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)

Sister Document - Restore MySQL from Amazon S3 - read that next

1 - Install s3cmd

this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc

View gist:f6362f8d97eb87b4a060
Randwick - 1 year - site wide - traffic graph
SELECT COUNT(DISTINCT user_id, user_type) as count, DATE( FROM_UNIXTIME(date)) as created_on FROM `beta_reports_user_session_types` WHERE `beta_reports_user_session_types`.`site_id` = 224 AND `beta_reports_user_session_types`.`project_id` IN (2788, 2804, 2797, 2816, 2800, 5060, 7397, 2822, 7611, 6445, 6617, 4217, 2808, 6731, 2813, 6744, 5046, 2792, 6953, 2809, 2805, 2823, 2799, 2810, 2827, 2795, 2794, 2791, 2825, 2819, 2821, 2824, 2978, 2798, 6619, 2811, 2787, 2801, 2807, 2989, 2826, 8019, 2786, 2814, 2790, 2818, 2820, 5690, 2806, 2796, 2793, 2803, 2789, 2785, 2815, 6298, 2817, 2802, 2812, 2828) AND (`beta_reports_user_session_types`.`date` BETWEEN 1387426750 AND 1417492931) GROUP BY created_on ORDER BY created_on
On demo server
| 110 | 2014-11-15 |
| 157 | 2014-11-16 |
+-------+------------+
332 rows in set (16.82 sec)
View file_splitter.rb
# Usage: FileSplitter.new('/usr/share/dict/words').split_into 10
class FileSplitter
def initialize(path)
@file = File.open path
end
def split_into(n)
i = 1
m = slice_size(n)
@unnitallman
unnitallman / gist:8802165
Created Feb 4, 2014
Rails UJS extension to add 'prompt'
View gist:8802165
/*
How to use:
%= link_to 'link text', url, data: {prompt: 'Enter your password', param-name: 'password', method: :delete}
*/
RailsJSPrompt = {
prompt: function(l){
@unnitallman
unnitallman / gist:8277938
Created Jan 6, 2014
To speed up github actions, by maintaining an ssh connection. Add the lines below to ~/.ssh/config
View gist:8277938
ControlMaster auto
ControlPath /tmp/%r@%h:%p
ControlPersist yes
@unnitallman
unnitallman / gist:7448221
Created Nov 13, 2013
Convert twitter username to user id
View gist:7448221
Add the gem "twitter" to Gemfile.
client = Twitter::Client.new(
:consumer_key => "key",
:consumer_secret => "secret",
)
[8] pry(main) client.users("unnitallman")[0].id
=> 11976602
You can’t perform that action at this time.