Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Uysim Uysim

🏠
Working from home
View GitHub Profile
@Uysim
Uysim / move-carrierwave-image-from-s3-to-local.rb
Created Nov 1, 2016
this gist code use for move your carrirerwave file from assets s3 of amazon to you local file.
View move-carrierwave-image-from-s3-to-local.rb
CarrierWave.configure do |config|
config.storage = :fog
config.fog_credentials = {
provider: 'AWS',
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
region: ENV['FOG_REGION']
}
config.fog_directory = ENV['S3_BUCKET_NAME']
end
@Uysim
Uysim / params_handler.js
Last active Nov 23, 2016
this script use for custom url params and redirect it
View params_handler.js
// new ParamsHandler({ location_id: object.id, page: 1 }).redirect();
window.ParamsHandler = (function() {
function ParamsHandler(params) {
this.params = params;
this.kvp = document.location.search.substr(1).split('&');
}
ParamsHandler.prototype.redirect = function() {
this._mapParams();
@Uysim
Uysim / humanize.coffee
Last active Nov 21, 2016
Coffeescript helper convert object into human readable (under development)
View humanize.coffee
window.Humanize =
# Humanize.numberToCurrency(100) => "$100"
# Humanize.numberToCurrency(10000) => "$10,000"
# Humanize.numberToCurrency(50.0501) => "$50.0501"
# Humanize.numberToCurrency(50.0501, { precision: 2 }) => "$50.05"
# Humanize.numberToCurrency(50, { unit: '£' }) => "£50"
# Humanize.numberToCurrency(10000, { delimiter: ';' }) => "$10;000"
numberToCurrency: (number, paramsOptions={})->
defaultOptions =
@Uysim
Uysim / humanize.js
Last active Nov 21, 2016
Javasript helper convert object into human readable (under development)
View humanize.js
window.Humanize = {
// Humanize.numberToCurrency(100) => "$100"
// Humanize.numberToCurrency(10000) => "$10,000"
// Humanize.numberToCurrency(50.0501) => "$50.0501"
// Humanize.numberToCurrency(50.0501, { precision: 2 }) => "$50.05"
// Humanize.numberToCurrency(50, { unit: '£' }) => "£50"
// Humanize.numberToCurrency(10000, { delimiter: ';' }) => "$10;000"
numberToCurrency: function(number, paramsOptions) {
var defaultOptions, delimited, delimiter, fixed, options, precision, unit;
@Uysim
Uysim / animate-mixin.scss
Last active Nov 21, 2016
common scss mixin helper that is useful
View animate-mixin.scss
// Define animation name, and properties
/*
@include keyframes(fade-out) {
0% { opacity: 1; }
90% { opacity: 0; }
}
*/
@mixin keyframes($animation-name) {
@-webkit-keyframes #{$animation-name} {
@content;
@Uysim
Uysim / background_print.coffee
Created Dec 9, 2016
Background print is use for print page without open in tab. Its purpose use for print PDF.
View background_print.coffee
# new BackgroundPrint('http://book.pdf').print()
class window.BackgroundPrint
constructor: (url)->
@url = url
print: ->
@_createFrame()
@_handleFrameLoad()
@_loadFrame()
@Uysim
Uysim / clone-schema-on-postgres.sh
Created Dec 23, 2016
This script use to clone postgres Schema
View clone-schema-on-postgres.sh
pg_dump --schema='source_schema' database_name | sed 's/source_schema/destination_schema/g' | psql -d database_name
@Uysim
Uysim / js_datetime.js
Created Jan 3, 2017
This gist describe about how to work with js DateTime
View js_datetime.js
// Get current date time
var currentDate = new Date();
// get date
var date = currentDate.getDate();
// get month index (January is 0)
var month = currentDate.getMonth();
// get year
@Uysim
Uysim / nondigest_assets.rake
Created May 21, 2017
This gist is rake for rails copy digest to nondigest assets
View nondigest_assets.rake
namespace :nondigest do
desc "TODO"
task precompile: :environment do
fingerprint = /\-[0-9a-f]{64}\./
filemap = {}
Dir["public/assets/**/*"].each do |file|
next if file !~ fingerprint
next if File.directory?(file)
nondigest = file.sub fingerprint, '.'
@Uysim
Uysim / laravel.js
Created Jun 6, 2017 — forked from JeffreyWay/laravel.js
Want to send a DELETE request when outside of a form? This will handle the form-creation bits for you dynamically, similar to the Rails implementation. (Requires jQuery, but doesn't have to.) To use, import script, and create a link with the `data-method="DELETE"` attribute.
View laravel.js
/*
<a href="posts/2" data-method="delete"> <---- We want to send an HTTP DELETE request
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-confirm="Are you sure?">
*/
(function() {