Skip to content

Instantly share code, notes, and snippets.

View lingceng's full-sized avatar

Kexian Zhong lingceng

View GitHub Profile
@ayamomiji
ayamomiji / list.html
Last active June 14, 2024 06:08
Stimulus example: smart scroll
<div data-controller="smart-scroll"
data-action="smart-scroll:added->smart-scroll#handleAdded
resize->smart-scroll#handleAdded
scroll->smart-scroll#handleScroll">
<div data-controller="smart-scroll-item">
aya: an an
</div>
<div data-controller="smart-scroll-item">
hatate: ni hao
</div>
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@bpierre
bpierre / README.md
Last active February 15, 2024 18:40
Switch To Vim For Good

Switch To Vim For Good

NOTE: This guide has moved to https://github.com/bpierre/switch-to-vim-for-good

This guide is coming from an email I used to send to newcomers to Vim. It is not intended to be a complete guide, it is about how I switched myself.

My decision to switch to Vim has been made a long time ago. Coming from TextMate 1, I wanted to learn an editor that is Open Source (so I don’t lose my time learning a tool that can be killed), cross platform (so I can use it everywhere), and powerful enough (so I won’t regret TextMate). For these reasons, Vim has always been the editor I wanted to learn, but it took me several years before I did it in a way that works for me. I tried to switch progressively, using the Janus Vim distribution for a few months, then got back to using TextMate 2 for a time, waiting for the next attempt… here is what finally worked for me.

Original gist with comments: https://gist.github.com/bpierre/0a0025d348b6001394e0

@obfusk
obfusk / break.py
Last active July 16, 2024 11:26
python "breakpoint" (more or less equivalent to ruby's binding.pry); for a proper debugger, use https://docs.python.org/3/library/pdb.html
import code; code.interact(local=dict(globals(), **locals()))
@eric1234
eric1234 / README.md
Last active August 29, 2015 13:58
Automatically translated snake_case method calls into their CamelCase equal

A module to automatically translate snake_case method calls into CamelCase method calls. For example:

class MyObject
  include Snakeable
  
  def FooBar
    "baz"
  end

end

@swordray
swordray / nginx_gzip.conf
Last active December 16, 2015 13:11
Nginx GZip configuration
gzip on;
gzip_comp_level 9;
gzip_min_length 1024;
gzip_buffers 4 8k;
gzip_types application/javascript application/json application/x-javascript application/xml text/css text/csv text/plain;
gzip_disable "MSIE [1-6]\.";
@rkh
rkh / warning_filter.rb
Created February 21, 2014 07:45
Run Ruby with warnings enabled. Without going crazy.
require 'delegate'
module Support
class WarningFilter < DelegateClass(IO)
def write(line)
super if line !~ /^\S+gems\/ruby\-\S+:\d+: warning:/
end
end
end
@swordray
swordray / nginx_rails.conf
Last active March 20, 2016 08:00
Nginx conf for Rails app
upstream project {
server 127.0.0.1:4000;
server unix://project/tmp/puma/puma.sock;
}
server {
listen 80;
server_name _;
access_log /var/log/nginx/project.access.log;
error_log /var/log/nginx/project.error.log;
# .railsrc
-B #Skip Bundle
-T #Skip Test-Unit
-d postgresql #Use postgres
@mikesmullin
mikesmullin / watch.sh
Last active April 26, 2023 05:20
watch is a linux bash script to monitor file modification recursively and execute bash commands as changes occur
#!/usr/bin/env bash
# script: watch
# author: Mike Smullin <mike@smullindesign.com>
# license: GPLv3
# description:
# watches the given path for changes
# and executes a given command when changes occur
# usage:
# watch <path> <cmd...>
#