Skip to content

Instantly share code, notes, and snippets.

View Uysim's full-sized avatar
🌏
Remote

Uysim Uysim

🌏
Remote
View GitHub Profile
@Uysim
Uysim / move-carrierwave-image-from-s3-to-local.rb
Created November 1, 2016 04:57
this gist code use for move your carrirerwave file from assets s3 of amazon to you local file.
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 November 23, 2016 04:47
this script use for custom url params and redirect it
// 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 November 21, 2016 04:58
Coffeescript helper convert object into human readable (under development)
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 November 21, 2016 05:00
Javasript helper convert object into human readable (under development)
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 November 21, 2016 04:31
common scss mixin helper that is useful
// 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 December 9, 2016 06:49
Background print is use for print page without open in tab. Its purpose use for print PDF.
# 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 December 23, 2016 03:09
This script use to clone postgres Schema
pg_dump --schema='source_schema' database_name | sed 's/source_schema/destination_schema/g' | psql -d database_name
@Uysim
Uysim / js_datetime.js
Created January 3, 2017 09:58
This gist describe about how to work with js DateTime
// 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 10:56
This gist is rake for rails copy digest to nondigest assets
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 June 6, 2017 06:53 — 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.
/*
<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() {