Skip to content

Instantly share code, notes, and snippets.

View niten2's full-sized avatar
🏠
Working from home

niten2 niten2

🏠
Working from home
  • Krasnoyarsk
View GitHub Profile
@eduardo-matos
eduardo-matos / rabbit-graceful-shutdown.js
Last active July 8, 2024 15:40
RabbitMQ graceful shutdown in NodeJS
const amqp = require('amqplib');
const uuid = require('uuid')
const CONSUMER_TAG = uuid.v4();
const QUEUE_NAME = 'my_queue'
async function main() {
const conn = await amqp.connect('amqp://guest:guest@localhost:5672/%2F');
const channel = await conn.createChannel();
await channel.assertQueue(QUEUE_NAME);
@vvaezian
vvaezian / Country Names with Abbreviations.csv
Last active November 18, 2022 12:57
Country names together with their ISO 3166-1 alpha-2 codes
Andorra AD
United Arab Emirates AE
Afghanistan AF
Antigua and Barbuda AG
Anguilla AI
Albania AL
Armenia AM
Angola AO
Antarctica AQ
Argentina AR
@s3rgeym
s3rgeym / Arch-Install-SED-Luks-Btrfs.md
Last active April 3, 2025 18:03
Установка Arch Linux с шифрованием всего диска либо раздела и Btrfs

image

Вся суть харча™ (на самом деле все далеко не так...)

Установка Arch Linux с шифрованием всего диска либо раздела и Btrfs

@gdamjan
gdamjan / 0-README.md
Last active November 17, 2023 22:07
hacking the kindle paperwhite

TODO - hack the kindle paperwhite

focus on the gen 2 / DP75SDI

compile kernel + initramfs with openwrt:

  • because it cross-compiles easily
  • has a reasonably simple user-space
  • device-tree?

CONFIG_PACKAGE_kmod-usb-gadget-serial

@onildoaguiar
onildoaguiar / sorting-an-array-by-date-with-moment-js.md
Last active May 21, 2024 15:15
Sorting an array by date with Moment.js
const Moment = require('moment')
const array = [{date:"2018-05-11"},{date:"2018-05-12"},{date:"2018-05-10"}]
const sortedArray  = array.sort((a,b) => new Moment(a.date).format('YYYYMMDD') - new Moment(b.date).format('YYYYMMDD'))
console.log(sortedArray)
@lolmaus
lolmaus / ❤lodash❤.md
Created December 20, 2017 12:14
Часто используемые методы lodash
  • groupBy -- разбивает массив на подмассивы по критерию
  • keyBy -- то же самое, когда критерий не повторяется
  • map, forEach, find умеют обходить объекты, очень удобно
  • mapKeys, mapValues -- преобразование объектов
  • toPairs и fromPairs -- преобразовывает {foo: 'bar'} в [['foo', 'bar']] и обратно
  • intersection, difference, union -- взаимодействие нескольких массивов
  • flatten -- без него вообще не жизнь
  • flatMap -- map+flatten, очень удобно
  • findIndex, sortedIndex -- когда тебе нужен только индекс элемента, а не сам элемент
  • findKey -- когда нужно найти ключ в объекте по критерию
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
@AshikNesin
AshikNesin / react-file-upload.js
Created February 2, 2017 06:46
Simple React File Upload
import React from 'react'
import axios, { post } from 'axios';
class SimpleReactFileUpload extends React.Component {
constructor(props) {
super(props);
this.state ={
file:null
}
@jbaxleyiii
jbaxleyiii / test.js
Created November 15, 2016 19:43
react-apollo testing
import { Component } from "react";
import { print } from "graphql-tag/printer";
import { graphql } from "react-apollo";
import { MockedProvider } from "react-apollo/test-utils";
import { addTypenameToDocument } from "apollo-client/queries/queryTransform";
import { mount } from "enzyme";
import { withSavedPayments, SAVED_ACCTS_QUERY } from "../";
@mooniker
mooniker / roles_investigation.md
Last active December 26, 2024 09:49 — forked from facultymatt/roles_invesitgation.md
Roles and permissions system for Nodejs

ACL / Roles + Permissions

Virgen-ACL (virgen-acl)

  • https://github.com/djvirgen/virgen-acl
  • "Simple in-memory ACL for node.js apps. Supports arbitrary roles and resources, including role/resource detection using a simple interface. Additionally supports custom assertions for more complex rules."
  • Comments: "Simple and elegant, create your own checks. No middleware?"

Node ACL (acl) BuildStatusDependency StatusdevDependency Status