Skip to content

Instantly share code, notes, and snippets.

View farbodsalimi's full-sized avatar

Farbod Salimi farbodsalimi

View GitHub Profile
SELECT table,
formatReadableSize(sum(bytes)) as size,
min(min_date) as min_date,
max(max_date) as max_date
FROM system.parts
WHERE active
GROUP BY table
@farbodsalimi
farbodsalimi / docker-compose.yml
Last active February 19, 2022 18:44
DynamoDB
version: '3.8'
services:
dynamodb-local:
command: '-jar DynamoDBLocal.jar -sharedDb -dbPath ./data'
image: 'amazon/dynamodb-local:latest'
container_name: dynamodb-local
ports:
- '8000:8000'
volumes:
- './docker/volumes/dynamodb:/home/dynamodblocal/data'

How to run Kaniko locally without k8s:

  1. Go to your project's directory

  2. Tar up the folder:

tar -C . -zcvf context.tar.gz .

SOLID Principles

  • SRP: Single responsibility Principle
  • OCP: The Open/Closed Principle
  • LSP: The Liskov Substitution Principle
  • ISP: The Interface Segregation Principle
  • DIP: The dependency Inversion Principle

Open/Closed Principle

const mongoose = require('mongoose'); // 5.0.17
const MONGO_DB = 'mongodb://localhost/yourdatabasename';
mongoose.connect(MONGO_DB);
mongoose.connection.on('open', async () => {
const collections = await mongoose.connection.db.listCollections().toArray();
console.log(collections);
var collection = mongoose.connection.db.collection('collectionname');
class EventEmitter {
constructor() {
this.events = {};
}
on(eventName, callback) {
if (this.events[eventName]) {
this.events[eventName].push(callback);
} else {
this.events[eventName] = [callback];
const ThemeContext = React.createContext("light");
// Example HOC
function withTheme(ThemedComponent) {
function ThemeContextInjector(props) {
return (
<ThemeContext.Consumer>
{value => (
<ThemedComponent {...props} ref={props.forwardedRef} theme={value} />
)}
const memoize = fn => {
const cache = {};
return (...args) => {
if (cache[args]) return cache[args];
cache[args] = fn.apply(this, args);
return cache[args];
};
};
const createDOM = type => (props = {}) => children => ({
type,
props,
children
});
const buildTree = node => {
if (!node) return;
const { type, props, children } = node;
@farbodsalimi
farbodsalimi / nginx
Created January 19, 2018 23:16
Nginx HTTPS config
server {
listen 80;
listen [::]:80;
server_name <SERVER_NAME> xxx.yoursite.com;
return 301 https://xxx.yoursite.com$request_uri;
}
server {
listen 443 ssl;
server_name <SERVER_NAME>;