Skip to content

Instantly share code, notes, and snippets.

View vin0010's full-sized avatar

Vinoth G vin0010

View GitHub Profile
# == Schema Information
#
# Table name: users
#
# id :bigint(8) not null, primary key
# status :integer(4) default("pending")
class User < ApplicationRecord
enum status: {
pending: 0,
active: 1,
@kislayverma
kislayverma / steve-yegge-platform-rant-follow-up.md
Created December 26, 2019 07:14
The one after platforms where Steve Yegge shares Amazon war stories

By Steve Yegge

Last week I accidentally posted an internal rant about service platforms to my public Google+ account (i.e. this one). It somehow went viral, which is nothing short of stupefying given that it was a massive Wall of Text. The whole thing still feels surreal.

Amazingly, nothing bad happened to me at Google. Everyone just laughed at me a lot, all the way up to the top, for having committed what must be the great-granddaddy of all Reply-All screwups in tech history.

But they also listened, which is super cool. I probably shouldn’t talk much about it, but they’re already figuring out how to deal with some of the issues I raised. I guess I shouldn’t be surprised, though. When I claimed in my internal post that “Google does everything right”, I meant it. When they’re faced with any problem at all, whether it’s technical or organizational or cultural, they set out to solve it in a first-class way.

Anyway, whenever something goes viral, skeptics start wondering if it was faked or staged. My accident

@PTKC
PTKC / SomeComponent.tsx
Last active October 22, 2023 15:31
Google Autocomplete Example with Ant Design
import { Card, Col, Divider, Form, Input, Row } from "antd";
import { LocationSearchInput } from "./location-search";
import { geocodeByAddress, getLatLng } from "react-places-autocomplete";
import { FormComponentProps } from "antd/lib/form/Form";
type Props = {} & FormComponentProps;
type State = {
address: string;
};
@sejr
sejr / App.tsx
Last active September 17, 2020 08:19
Firebase Authentication with React Hooks
import React, { useState, useEffect } from 'react';
import { auth } from '../firebase';
type FirebaseUserState = firebase.User | null;
const SignIn = () => {
let [email, setEmail] = useState('');
let [password, setPassword] = useState('');
let [loading, setLoading] = useState(false);
@binhtran04
binhtran04 / PrivateRoute.js
Created November 30, 2018 19:01
Private route component
import React from 'react';
import { Route, Redirect } from 'react-router-dom';
import { isLogin } from '../utils';
const PrivateRoute = ({component: Component, ...rest}) => {
return (
// Show the component only when the user is logged in
// Otherwise, redirect the user to /signin page
<Route {...rest} render={props => (
@sandcastle
sandcastle / copy-to-clipboard.ts
Created July 17, 2017 06:38
A copy to clipboard function (in typescript)
export const copyToClipboard = (url: string) => {
document.addEventListener('copy', (e: ClipboardEvent) => {
e.clipboardData.setData('text/plain', url);
e.preventDefault();
document.removeEventListener('copy');
});
document.execCommand('copy');
};
@codediodeio
codediodeio / database.rules.json
Last active June 1, 2024 14:26
Common Database Rules for Firebase
// No Security
{
"rules": {
".read": true,
".write": true
}
}
@wojteklu
wojteklu / clean_code.md
Last active June 2, 2024 09:58
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@foxumon
foxumon / csv_export.rb
Created April 29, 2016 20:19
Export table to CSV with all attributes in rails console
require 'csv'
file = "#{Rails.root}/public/data.csv"
table = User.all;0 # ";0" stops output. Change "User" to any model.
CSV.open( file, 'w' ) do |writer|
writer << table.first.attributes.map { |a,v| a }
table.each do |s|
writer << s.attributes.map { |a,v| v }
@truncs
truncs / trie.py
Created January 29, 2012 20:20
Simple Trie in python
#! /usr/bin/python
import unittest
class Trie(object):
""" Trie implementation in python
"""
def __init__(self, ):
""" So we use a dictionary at each level to represent a level in the hashmap