Skip to content

Instantly share code, notes, and snippets.

View dmorenogogoleva's full-sized avatar
:electron:
=^_^=

Daria Moreno-Gogoleva dmorenogogoleva

:electron:
=^_^=
View GitHub Profile
/**
* Sum two big numbers given as strings.
*
* @param {string} a
* @param {string} b
* @return {string}
*/
function sumStrings(a, b) {
var zrx = /^0+/; // remove leading zeros
a = a.replace(zrx, '').split('').reverse();
@pafnuty
pafnuty / declination.js
Last active December 11, 2024 10:03
Склонение русских слов на javascript и php с идентичной реализацией передачи параметров
/**
* Функция для склонения русских слов
* Пример использования: ruDeclination(5,'комментари|й|я|ев')
*
* @author Павел Белоусов <[email protected]>
*
* @param {number} number Число, для которого будет расчитано окончание
* @param {string} words Слово и варианты окончаний для 1|2|1 (1 комментарий, 2 комментария, 100 комментариев)
* @return {string} Cлово с правильным окончанием
*/
@wilddeer
wilddeer / flexbox-adventures.md
Last active November 29, 2018 05:54
Невероятные приключения флексбокса в фаерфоксе

Невероятные приключения флексбокса в фаерфоксе

  • Блок с прокруткой в вертикальном флексбоксе не работает — ставить max-height: 100% на контейнер
  • word-wrap: break-word не работает внутри флексбокса — спасает min-width: 0 на элементе флексбокса (overflow-x: hidden тоже работает)
  • Флексбокс не работает на кнопке — класть внутрь блок и на нем делать флексбокс
  • Элемент флексбокса с ellipsis расфигачивает все по ширинеmin-width: 0 на флексбокс / max-width: 100% на самого верхнего разъехавшегося родителя
  • Элементы флексбокса не выравниваются по базовой линии, если внутри еще один флексбокс — использовать inline-flex

О других невероятных приключениях вы узнаете в следующей серии

@katychuang
katychuang / remove_brew-mongo_osx.sh
Last active August 3, 2024 16:45
remove mongodb that was installed via brew
#!/usr/bin/env sh
# first check to see if mongo service is running. you can't delete any files until the service stops so perform a quick check.
launchctl list | grep mongo
# NOTE: the pipe | symbol means the commands on the right performs on the output from the left
# grep is a string search utility. `grep mongo` means search for the substring mongo
# use the unload command to end the mongo service. this is required to 'unlock' before removing the service.
# first look for the file to delete
MONGO_SERVICE_FILE=$(ls ~/Library/LaunchAgents/*mongodb*)
@CrookedNumber
CrookedNumber / gist:8964442
Created February 12, 2014 21:02
git: Removing the last commit

Removing the last commit

To remove the last commit from git, you can simply run git reset --hard HEAD^ If you are removing multiple commits from the top, you can run git reset --hard HEAD~2 to remove the last two commits. You can increase the number to remove even more commits.

If you want to "uncommit" the commits, but keep the changes around for reworking, remove the "--hard": git reset HEAD^ which will evict the commits from the branch and from the index, but leave the working tree around.

If you want to save the commits on a new branch name, then run git branch newbranchname before doing the git reset.

@rxaviers
rxaviers / gist:7360908
Last active April 22, 2025 01:30
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@adamjohnson
adamjohnson / publickey-git-error.markdown
Last active January 30, 2025 00:44
Fix "Permission denied (publickey)" error when pushing with Git

"Help, I keep getting a 'Permission Denied (publickey)' error when I push!"

This means, on your local machine, you haven't made any SSH keys. Not to worry. Here's how to fix:

  1. Open git bash (Use the Windows search. To find it, type "git bash") or the Mac Terminal. Pro Tip: You can use any *nix based command prompt (but not the default Windows Command Prompt!)
  2. Type cd ~/.ssh. This will take you to the root directory for Git (Likely C:\Users\[YOUR-USER-NAME]\.ssh\ on Windows)
  3. Within the .ssh folder, there should be these two files: id_rsa and id_rsa.pub. These are the files that tell your computer how to communicate with GitHub, BitBucket, or any other Git based service. Type ls to see a directory listing. If those two files don't show up, proceed to the next step. NOTE: Your SSH keys must be named id_rsa and id_rsa.pub in order for Git, GitHub, and BitBucket to recognize them by default.
  4. To create the SSH keys, type ssh-keygen -t rsa -C "[email protected]". Th
@realmyst
realmyst / gist:1262561
Created October 4, 2011 19:34
Склонение числительных в javascript
function declOfNum(number, titles) {
cases = [2, 0, 1, 1, 1, 2];
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ];
}
use:
declOfNum(count, ['найдена', 'найдено', 'найдены']);