This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'mina/git' | |
require 'json' | |
set :domain, '0.0.0.0' | |
set :user, 'nodejs' | |
set :deploy_to, '/home/nodejs/api' | |
set :repository, 'git@.../api.git' | |
set :branch, 'master' | |
set :shared_paths, [ 'tmp' ] | |
set :term_mode, :pretty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SECRET_KEY = ENTER YOUR SECRET KEY HERE; | |
const MAX_TOKENS = 200; | |
// For more cool AI snippets and demos, follow me on Twitter: https://twitter.com/_abi_ | |
/** | |
* Completes your prompt with GPT-3 | |
* | |
* @param {string} prompt Prompt | |
* @param {number} temperature (Optional) Temperature. 1 is super creative while 0 is very exact and precise. Defaults to 0.4. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'openssl' | |
class String | |
def encrypt(key) | |
cipher = OpenSSL::Cipher.new('DES-EDE3-CBC').encrypt | |
cipher.key = Digest::SHA1.hexdigest key | |
s = cipher.update(self) + cipher.final | |
s.unpack('H*')[0].upcase | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{url:'stun:stun01.sipphone.com'}, | |
{url:'stun:stun.ekiga.net'}, | |
{url:'stun:stun.fwdnet.net'}, | |
{url:'stun:stun.ideasip.com'}, | |
{url:'stun:stun.iptel.org'}, | |
{url:'stun:stun.rixtelecom.se'}, | |
{url:'stun:stun.schlund.de'}, | |
{url:'stun:stun.l.google.com:19302'}, | |
{url:'stun:stun1.l.google.com:19302'}, | |
{url:'stun:stun2.l.google.com:19302'}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="keysleft"> | |
move: WASD | |
<br>Hold/Drop/Fire(hold it): E | |
<br>Pause: F | |
<br>Gravity: R | |
<br>Have fun | |
</div> | |
<div id="keysright"> | |
zoom: + - | |
<br>fire: click |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query | |
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails | |
#payload: [{"kind"=>"person"}] | |
Segment.where("payload @> ?", [{kind: "person"}].to_json) | |
#data: {"interest"=>["music", "movies", "programming"]} | |
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json) | |
Segment.where("data #>> '{interest, 1}' = 'movies' ") | |
Segment.where("jsonb_array_length(data->'interest') > 1") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root = document.querySelector('#shortcut-menu'); | |
element = document.querySelector("#render_async_bf86d55cff1564565792") | |
var observer = new IntersectionObserver(function(entries) { | |
console.log("interaction ", entries) | |
if (entries[0].intersectionRatio) { | |
console.log('visible'); | |
} else { | |
console.log('hidden'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = "ุจูุณูู ู ูฑูููููู ูฑูุฑููุญูู ููฐูู ูฑูุฑููุญููู ู" | |
text.gsub(/\u0FDF0|\u0FDF1|\u0066D|\u0061F|\u060F|\u060E|\u060D|\060C|\u060B|\u064C|\u064D|\u064E|\u064F|\u0650|\u0651|\u0652|\u0653|\u0654|\u0655|\u0656|\0657|\u0658/, '') | |
#=> ุจุณู ูฑููู ูฑูุฑุญู ูฐู ูฑูุฑุญูู |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove all branches except master and develop | |
git branch | grep -v "master\|develop" | xargs git branch -D | |
# Even better, create a git alias | |
git config --global alias.clean-branches "!git branch | grep -v "master\|develop" | xargs git branch -D" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark/ips' | |
def find_one_using_group_by_select(array) | |
array.group_by{ |e| e }.detect { |k, v| k if v.size > 1 }&.first | |
end | |
def find_one_using_chunk_select(array) | |
array.sort.chunk{ |e| e }.detect { |e, chunk| chunk.size > 1 }&.first | |
end |
NewerOlder