Skip to content

Instantly share code, notes, and snippets.

View vikdotdev's full-sized avatar
📎

Viktor Habchak vikdotdev

📎
View GitHub Profile
@chetan
chetan / yardoc_cheatsheet.md
Last active July 22, 2025 02:26
YARD cheatsheet
@sedm0784
sedm0784 / CapsLockCtrlEscape.ahk
Last active October 12, 2025 05:46
AutoHotkey script to map Caps Lock to Escape when it's pressed on its own and Ctrl when used in combination with another key, à la Steve Losh. Adapted from one that does something similar with the Ctrl Key on the Vim Tips Wiki (http://vim.wikia.com/wiki/Map_caps_lock_to_escape_in_Windows?oldid=32281). (Plus contribs from @randy909 & @mmikeww.)
g_LastCtrlKeyDownTime := 0
g_AbortSendEsc := false
g_ControlRepeatDetected := false
*CapsLock::
if (g_ControlRepeatDetected)
{
return
}
@atenni
atenni / README.md
Last active September 24, 2025 01:05
How to permalink to a gist's raw file

Problem: When linking to the raw version of a gist, the link changes with each revision.

Solution:

To return the first file from a gist: https://gist.github.com/[gist_user]/[gist_id]/raw/

To get a file from multi–file gist: https://gist.github.com/[gist_user]/[gist_id]/raw/[file_name]

@joyrexus
joyrexus / README.md
Last active September 6, 2025 15:46 — forked from liamcurry/gist:2597326
Vanilla JS equivalents of jQuery methods

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@tekkies
tekkies / indented-checkboxes.md
Last active October 5, 2023 02:59
Indented markdown checkbox example

Nested checkbox rendering would be nice (view the sourcer for this gist)

  • Task 1
  • Task 2
    • Subtask a
    • Subtask b
  • Task 3

There's no need to complete parents when child nodes are all checked.

# this scrubs emoji sequences from a string - i think it covers all of them
def strip_emoji ( str )
str = str.force_encoding('utf-8').encode
clean_text = ""
# emoticons 1F601 - 1F64F
regex = /[\u{1f600}-\u{1f64f}]/
clean_text = str.gsub regex, ''
@demisx
demisx / active_record_objects_autosave.md
Last active July 4, 2024 14:20
When Active Record Child Objects are Autosaved in Rails

belongs_to:

  1. Assigning an object to a belongs_to association does not automatically save the object. It does not save the associated object either.

has_one:

  1. When you assign an object to a has_one association, that object is automatically saved (in order to update its foreign key).
  2. In addition, any object being replaced is also automatically saved, because its foreign key will change too
  3. If either of these saves fails due to validation errors, then the assignment statement returns false and the assignment itself is cancelled.
  4. If the parent object (the one declaring the has_one association) is unsaved (that is, new_record? returns true) then the child objects are not saved. They will automatically when the parent object is saved.
@lfender6445
lfender6445 / gist:9919357
Last active October 8, 2025 09:24
Pry Cheat Sheet

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@soheilhy
soheilhy / nginxproxy.md
Last active July 5, 2025 15:29
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@robinrendle
robinrendle / reset.css
Last active July 24, 2021 01:20
A CSS reset with sane defaults
/*Box sizing (the nuclear option) */
*, *:before, *:after {
-ms-box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing:border-box;
box-sizing: border-box;
}
/* Fix font rendering defaults */
html, button {