Skip to content

Instantly share code, notes, and snippets.

View absk1317's full-sized avatar
🎯
Focusing

abhishek verma absk1317

🎯
Focusing
View GitHub Profile
MAP = {
1 => ['I', 'V', 'X'],
2 => ['X', 'L', 'C'],
3 => ['C', 'D', 'M'],
4 => ['M', 'M', 'M']
}
def to_roman(numeral)
roman_numeral = ''
import React, { Component } from 'react';
import { ActivityIndicator } from 'react-native';
import NetInfo from '@react-native-community/netinfo';
import { connect } from 'react-redux';
import { setInternetStatus } from 'actions';
import { showToast } from '../utils/Library';
import PubSub from 'pubsub-js';
import { MESSAGE_TOPICS, Locales } from 'utils';
import { SemiBoldText } from 'components/common';
import { TextStyle, Row } from 'styles';
@absk1317
absk1317 / Api.js
Created August 20, 2020 09:44
Axios interceptor
import axios from 'axios';
import configureStore from './Store';
const { store } = configureStore();
const instance = axios.create({
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
}
@absk1317
absk1317 / SessionManager.js
Created August 20, 2020 09:40
Handling sessions with react native
import { Component } from 'react';
import { AppState } from 'react-native';
import { connect } from 'react-redux';
import { recordSomething } from 'some-component';
import { recordSomethingElse } from 'some-other-component';
import { storeSessionData } from 'redux/actions/sessions';
import * as Sentry from '@sentry/react-native';
import { navigator } from 'utils';
import { chatActions } from 'actions';
# frozen_string_literal: true
class BaseObserver < ActiveRecord::Observer
def create?(resource)
resource.send(:transaction_include_any_action?, [:create])
end
def deleted?(resource)
resource.send(:transaction_include_any_action?, [:destroy])
end
# frozen_string_literal: true
class ContactStorageWorker
include Sidekiq::Worker
sidekiq_options retry: false
attr_accessor :user_id, :contact_params
def perform(contact_params, user_id)
@user_id = user_id
@absk1317
absk1317 / users.rb
Last active August 20, 2020 09:11
Google Sheets Entries
# frozen_string_literal: true
# For abstracting out updating approved users sheet
class GoogleSheets::Users
SHEET_NAME = 'users'
QUEUE_NAME = 'google_sheet'
include Sidekiq::Worker
sidekiq_options queue: QUEUE_NAME
sidekiq_options lock: :until_and_while_executing
@absk1317
absk1317 / image.rb
Last active August 20, 2020 09:12
Async Image Processing
# frozen_string_literal: true
# == Schema Information
#
# Table name: images
#
# id :bigint not null, primary key
# deleted_at :datetime indexed
# height :decimal(, )
# image :string
server {
server_name xyz.com;
root /home/ubuntu/www;
large_client_header_buffers 4 16k;
client_max_body_size 4G;
keepalive_timeout 10;
gzip_static on;
# encoding: utf-8
Model.new(:producion_backup, 'Description for producion_backup') do
archive :configs do |archive|
archive.add "/home/ubuntu/projects/api/shared/config/"
archive.add '/etc/nginx/'
end
database PostgreSQL do |db|
db.name = "db_name"