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 = ''
@absk1317
absk1317 / clear_gitlab_artifacts.rb
Created September 16, 2019 09:40
delete old gitlab artifacts
require 'httparty'
token = 'YOUR_TOKEN'
project_id = 'PROJECT_ID'
query = { per_page: 100 }
headers = { "PRIVATE-TOKEN" => token }
server = "https://gitlab.com/api/v4/projects/#{project_id}/jobs"
response = HTTParty.get(server, query: query, headers: headers)
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';
@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
@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
# 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
# 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
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;