Skip to content

Instantly share code, notes, and snippets.

@ishanray
ishanray / pre-push
Created May 1, 2018
Don't push to master
View pre-push
#!/bin/bash
protected_branch='master'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ $protected_branch = $current_branch ]
then
read -p "You're about to push master, is that what you intended? [y|n] " -n 1 -r < /dev/tty
echo
if echo $REPLY | grep -E '^[Yy]$' > /dev/null
@ishanray
ishanray / controller.rb
Last active Mar 24, 2018
file upload ajax
View controller.rb
bucket = Aws::S3::Bucket.new(name: 'truck-parts')
@signed_upload_url = bucket.presigned_post(
key: 'public/${filename}',
success_action_status: '201',
acl: 'public-read',
signature_expiration: 1.minute.from_now
)
@ishanray
ishanray / index.html
Created Mar 20, 2018
preview uploaded images
View index.html
<form id="form1" runat="server">
<input type='file' id="imgInp" multiple='true' />
<div id="preview"></div>
</form>
View hotel review
var lines = input.split('\n');
var wordlist = lines[0];
var wordScoresDict = {};
wordlist.map(word => wordScoresDict[word.toLowerCase()] = 0);
var hotels = [];
for (var i = 0, l = lines.length; i < l; i++) {
View Timezone Hash
displayedTimezones =
"Pacific/Midway" : "International Date Line West"
"Pacific/Midway" : "Midway Island"
"Pacific/Pago_Pago" : "American Samoa"
"Pacific/Honolulu" : "Hawaii"
"America/Juneau" : "Alaska"
"America/Los_Angeles" : "Pacific Time (US & Canada)"
"America/Tijuana" : "Tijuana"
"America/Denver" : "Mountain Time (US & Canada)"
"America/Phoenix" : "Arizona"
View time-picker.css
.timePicker {
list-style-type: none;
background-color: #fff;
width: 80px;
margin: 0;
padding: 0;
height: 200px;
overflow-y: auto;
box-shadow: 1px 1px 3px rgba(0,0,0,0.4);
font-family: sans-serif;
View time-picker.html
<div class="timePickerWrap">
<input ng-model="time" class="timePickerInput" type="text">
<ul ng-show="showTimeDropdown" class="timePicker">
<li>0:00 AM</li>
<li>0:30 AM</li>
<li>1:00 AM</li>
<li>1:30 AM</li>
<li>2:00 AM</li>
<li>2:30 AM</li>
<li>3:00 AM</li>
View timePicker.js
app.directive('timePicker', function(){
return {
restrict: 'A',
replace: true,
scope: {
time: '='
},
templateUrl: 'js/partials/time-picker.html',
link: function(scope, el, attr){