Skip to content

Instantly share code, notes, and snippets.

@c80609a
c80609a / facebook-tracking
Created March 10, 2023 16:49 — forked from antonromanov/facebook-tracking
facebook-tracking
<!-- Facebook All Pages -->
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','https://connect.facebook.net/en_US/fbevents.js');
fbq('init', {{WCA}});
fbq('track', "PageView", {
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# I don't remember where I found this. o_O
# Reset
Color_Off="\[\033[0m\]" # Text Reset
re = /([^&=]+)=?([^&]*)/g
decodeRE = /\+/g
decode = (str) -> decodeURIComponent(str.replace(decodeRE, " "))
assign = (obj, keyPath, value) ->
for i in [0...keyPath.length]
key = keyPath[i]
obj[key] = {} if !(key in obj)
obj = obj[key]
// Handles click on the button "🞮" - delete photo
class DelPhoto {
constructor(html_node) {
this.$btn = $(html_node)
this.btn_id = this.$btn.attr("id")
this.$photo_div = $('#'+this.btn_id.split('photo_delete_').join('photo_'))
this.ajaxSuccess = this.ajaxSuccess.bind(this)
this.check()
this.init()
@c80609a
c80609a / countries.json
Last active December 12, 2021 12:44
countries.json
[{"id":75,"titleEn":"Dominican Republic"},{"id":101,"titleEn":"Congo, Democratic Republic"},{"id":213,"titleEn":"Central African Republic"},{"id":215,"titleEn":"Czech Republic"}]
@c80609a
c80609a / scratch.rb
Created March 19, 2021 08:04
Devise Invitable - Manually send invitation token
user_to_invite = User.find(email: "peter.muster@test.com")
user_to_invite.deliver_invitation
token = user_to_invite.raw_invitation_token
@c80609a
c80609a / numbers.rb
Created January 2, 2021 11:23
Ruby number formatting
# g limits the number of displayed digits
"%.2g" % 1.234 # => 1.2
"%.2g" % 123 # => 1.2e+02
"%g" % 1000000000 # => 1e+09
# combined
"%g" % ("%.2f" % 2) #=> 2
"%g" % ("%.2f" % 2.50) #=> 2.5
"%g" % ("%.2f" % 12.543) #=> 12.54
@c80609a
c80609a / pull_request.txt
Created December 28, 2020 08:19
pull_request.txt
We have a policy of not adding new methods to Ruby
core classes unless it would benefit the framework
implementation or the large majority of
applications. For most cases I believe the required
keyword arguments are enough. This is actually the
case for assert_valid_keys as well since we can
change most calls to this method to keyword
arguments. To introduce this to 6.2 we need to show
that this would be useful for the framework, and
only two places don't are not enough. If you want
@c80609a
c80609a / rubocop.rb
Last active December 16, 2020 01:11
rubocop.rb
# Rubocop's Metrics/AbcSize metric is disabled for
# this method as Rubocop determines this method to
# be too complex while there's no way to make it
# less "complex" without introducing extra methods
# (which actually will make things _more_ complex).
@c80609a
c80609a / gist:6aecde852f7fa66cb0f70ab6755b955a
Created November 22, 2020 11:40
How to view the entire Rails console history?
puts Readline::HISTORY.to_a