Skip to content

Instantly share code, notes, and snippets.

View dtakahas's full-sized avatar
🏠
Working from home

Dave Takahashi dtakahas

🏠
Working from home
View GitHub Profile
@dtakahas
dtakahas / encoding.rb
Created August 9, 2016 23:51
Ruby String Encoding
2.1.5 :001 > utf = "".force_encoding("UTF-8")
=> ""
2.1.5 :002 > utf.encoding
=> #<Encoding:UTF-8>
2.1.5 :003 > ascii = "".force_encoding("ASCII-8BIT")
=> ""
2.1.5 :004 > ascii.encoding
=> #<Encoding:ASCII-8BIT>
2.1.5 :005 > example = "thisIsMyPath".force_encoding("UTF-8")
=> "thisIsMyPath"
require "http/client"
require "json"
client = HTTP::Client.new "https://www.google.com", 443, true
response = client.get "/"
# Crystal 0.14.2
# crystal run request.cr
# Outputs:
<%= vpi_button_to_function @readonly ? "Close" : "Cancel", cancel_js, :class => 'vpi_submit_button' %>
<%= button_to @readonly ? "Close" : "Cancel", class: 'vpi_submit_button', data: {function: "cancel-js"} %>
<% cancel_js = data_set.new_record? ? "$('##{data_set_row_id}').remove();" : "toggle_data_set('#{data_set.id}', '#{builder_id}', '#{data_set_row_id}'); return false;"%>
@dtakahas
dtakahas / babby.rb
Last active December 28, 2021 03:56
How is babby formed in Rails?
class Babby < PragnentGirl::GetPragnent
attr_accessible :name, :mother, :location, :pragnent_girl_id
belongs_to :pragnent_girl
before_save :destroy_instain_mothers
after_save :pary_for_father
#How is babby formed?