Skip to content

Instantly share code, notes, and snippets.

View quyen91's full-sized avatar
🌴
On vacation

quyencv quyen91

🌴
On vacation
View GitHub Profile
@bluzky
bluzky / slug.js
Last active April 8, 2024 05:01
Remove vietnamese accent javascript / Bỏ dấu tiếng Việt
function stringToSlug(str) {
// remove accents
var from = "àáãảạăằắẳẵặâầấẩẫậèéẻẽẹêềếểễệđùúủũụưừứửữựòóỏõọôồốổỗộơờớởỡợìíỉĩịäëïîöüûñçýỳỹỵỷ",
to = "aaaaaaaaaaaaaaaaaeeeeeeeeeeeduuuuuuuuuuuoooooooooooooooooiiiiiaeiiouuncyyyyy";
for (var i=0, l=from.length ; i < l ; i++) {
str = str.replace(RegExp(from[i], "gi"), to[i]);
}
str = str.toLowerCase()
.trim()
@cheeaun
cheeaun / rdrc2016.md
Last active June 13, 2018 08:39
RedDotRubyConf 2016 links & resources 😘
@khanhicetea
khanhicetea / Vagrantfile
Created December 5, 2015 17:36
PHP Box Vagrant
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@MrNice
MrNice / blogpost.md
Last active February 17, 2023 09:46
Explain how to think about ansible and how to use it

Ansible

Understanding Ansible

Ansible is a powerful, simple, and easy to use tool for managing computers. It is most often used to update programs and configuration on dozens of servers at once, but the abstractions are the same whether you're managing one computer or a hundred. Ansible can even do "fun" things like change the desktop photo or backup personal files to the cloud. It can take a while to learn how to use Ansible because it has an extensive terminology, but once you understand the why and the how of Ansible, its power is readily apparent.

Ansible's power comes from its simplicity. Under the hood, Ansible is just a domain specific language (DSL) for a task runner for a secure shell (ssh). You write ansible yaml (.yml) files which describe the tasks which must run to turn plain old / virtualized / cloud computers into production ready server-beasts. These tasks, in turn, have easy to understand names like "copy", "file", "command", "ping", or "lineinfile". Each of these turns into shell comma

@Phlow
Phlow / list-categories-count.liquid
Last active June 4, 2021 18:33
Jekyll: List all categories with according post count and show and link all post items listed in the according category
<h2>Categories</h2>
<ul>
{% assign categories_list = site.categories %}
{% if categories_list.first[0] == null %}
{% for category in categories_list %}
<li><a href="#{{ category | downcase | downcase | url_escape | strip | replace: ' ', '-' }}">{{ category | camelcase }} ({{ site.tags[category].size }})</a></li>
{% endfor %}
{% else %}
{% for category in categories_list %}
<li><a href="#{{ category[0] | downcase | url_escape | strip | replace: ' ', '-' }}">{{ category[0] | camelcase }} ({{ category[1].size }})</a></li>
@khanhicetea
khanhicetea / vietnam_locations.js
Created July 26, 2015 14:14
Vietnam Location Data
{"01":{"id":"01","name":"H\u00e0 N\u1ed9i","type":"Th\u00e0nh Ph\u1ed1","children":{"001":{"id":"001","name":"Ba \u0110\u00ecnh","type":"Qu\u1eadn","location":"21 02 08N, 105 49 38E","parent_id":"01","children":[]},"002":{"id":"002","name":"Ho\u00e0n Ki\u1ebfm","type":"Qu\u1eadn","location":"21 01 53N, 105 51 09E","parent_id":"01","children":[]},"003":{"id":"003","name":"T\u00e2y H\u1ed3","type":"Qu\u1eadn","location":"21 04 10N, 105 49 07E","parent_id":"01","children":[]},"004":{"id":"004","name":"Long Bi\u00ean","type":"Qu\u1eadn","location":"21 02 21N, 105 53 07E","parent_id":"01","children":[]},"005":{"id":"005","name":"C\u1ea7u Gi\u1ea5y","type":"Qu\u1eadn","location":"21 01 52N, 105 47 20E","parent_id":"01","children":[]},"006":{"id":"006","name":"\u0110\u1ed1ng \u0110a","type":"Qu\u1eadn","location":"21 00 56N, 105 49 06E","parent_id":"01","children":[]},"007":{"id":"007","name":"Hai B\u00e0 Tr\u01b0ng","type":"Qu\u1eadn","location":"21 00 27N, 105 51 35E","parent_id":"01","children":[]},"008":{"id":"0
  • Dynamic Dispatch
  • Dynamic Method
  • Ghost Methods
  • Dynamic Proxies
  • Blank Slate
  • Kernel Method
  • Flattening the Scope (aka Nested Lexical Scopes)
  • Context Probe
  • Class Eval (not really a 'spell' more just a demonstration of its usage)
  • Class Macros
@pcreux
pcreux / 0-gourmet-service-objects.md
Last active August 21, 2022 15:32
Gourmet Service Objects - Lightning Talk - http://vanruby.org - Feb 27, 2014

Gourmet Service objects

 @pcreux

 Feb 27, 2014
 http://vanruby.org
@Bijendra
Bijendra / upload-images-s3-sdk-ruby
Last active May 30, 2023 08:20
Upload images to AWS S3 in rails application using aws-sdk
Using gem aws-sdk for a ror application for uploading images to s3
Uploading images to a fixed bucket with different folders for each object or application.
The s3 keeps a limitation on the number of buckets creattion whereas there is no
limitation for content inside a bucket.
This code will upload image for a user to s3 using aws-sdk gem. The bucket and the image uploaded are made public
so that the images uploaded are directly accessible. The input it takes is the image complete path
where it is present, folder in which it should be uploaded and user_id for whom it should
be uploaded.