This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DataModel | |
include Enumerable | |
def initialize data | |
@data = data | |
end | |
def each | |
@data.each { |x| yield x } | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution | |
def reverse_integer(x) | |
# for the last result | |
sign = x < 0 ? -1 : 1 | |
x_clone = x.abs.dup | |
x_result = 0 | |
while x_clone > 0 | |
x_result = (x_result * 10) + x_clone % 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def use_scope_info | |
%i[klass content_key attributes_query current_usager_ids] | |
.each_with_object(ActiveSupport::OrderedOptions.new) do |k, object| | |
object[k] = USE_SCOPE_INFO.dig(k, usager_type.to_sym) | |
end | |
end | |
USE_SCOPE_INFO = { | |
klass: { | |
agents: Agent, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
value = :initial | |
catch :redo do | |
case value | |
when :initial | |
puts 'initial' | |
value = :changed | |
redo | |
when :changed | |
puts 'changed' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git config --global https.proxy http://127.0.0.1:1080 | |
git config --global https.proxy https://127.0.0.1:1080 | |
git config --global --unset http.proxy | |
git config --global --unset https.proxy | |
npm config delete proxy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int gcd(int p, int q) | |
{ | |
if (q == 0) return p; | |
int r = p % q; | |
return gcd(q, r); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
const translate = require('google-translate-api') | |
const langCodeFileMap = { | |
bn: 'bn', | |
en: 'en-us', | |
de: 'de', | |
el: 'el', | |
es: 'es', | |
fr: 'fr', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Signal catching | |
def shut_down | |
puts "\nShutting down gracefully..." | |
sleep 1 | |
end | |
puts "I have PID #{Process.pid}" | |
# Trap ^C | |
Signal.trap("INT") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Kill rails server and guard | |
bin/spring stop | |
brew services stop mysql | |
brew uninstall mysql | |
brew install [email protected] | |
brew link [email protected] --force | |
brew services start [email protected] | |
rbenv uninstall 2.3.3 | |
rbenv install 2.3.3 | |
gem install bundle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.list { | |
overflow: hidden; | |
} | |
[data-swipe="left"] { | |
width: 120%; | |
overflow: hidden; | |
-webkit-transition: all 0.5s ease; | |
-moz-transition: all 0.5s ease; | |
-o-transition: all 0.5s ease; |