Skip to content

Instantly share code, notes, and snippets.

View solancer's full-sized avatar
🎯
Focusing

Srinivas Gowda solancer

🎯
Focusing
View GitHub Profile
@solancer
solancer / concurrent_map_exception
Last active June 28, 2022 04:49
concurrent map
#!/usr/bin/env python3
'''
Usage:
./concurrent_map_exception.py [nproc [min [max]]
e.g.:
./concurrent_map_exception.py 2 -10 100
Outcome:
:80
encode gzip
root * /Users/shared/server/components/web
route {
reverse_proxy /soc/* 127.0.0.1:9710
reverse_proxy /api/* 127.0.0.1:9720
reverse_proxy /fio/* 127.0.0.1:9730
try_files {path} /index.html
file_server browse
@solancer
solancer / unity
Created February 17, 2022 07:48
unity
UnityWebRequest www = UnityWebRequest.Put(URL_01, "{\"name\":\"user_01\",\"address\":{\"raw\":\"MountFiji\"}}");
www.SetRequestHeader ("Content-Type", "application/json");
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
@solancer
solancer / crud-strapi-extend.js
Created February 15, 2022 13:58
crud strapi
'use strict';
const {
sanitizeEntity
} = require('strapi-utils');
const buildError = (httpStatus, payload) => {
return {
status: httpStatus,
body: JSON.stringify({
error: payload
@solancer
solancer / strapi_service.js
Created February 15, 2022 06:26
Replacing findOne in service - strapi
const { createCoreService } = require('@strapi/strapi').factories;
module.exports = createCoreService('api::pack.pack', ({ strapi }) => ({
// Method 3: Replacing a core service
async findOne(packId, params = {}) {
const entry = await strapi.db.query('api::pack.pack').findOne({
select: ['label', 'description', 'version'],
where: { packId: packId },
@solancer
solancer / NginxVirualhost.conf
Last active January 8, 2022 14:59
Configure Nginx SSL + force HTTP to redirect to HTTPS + force www to non-www
server {
listen 80;
server_name www.domain.com domain.com;
# redirects both www and non-www to ssl port with http (NOT HTTPS, forcing error 497)
return 301 http://domain.com$request_uri;
}
server {
listen 433 ssl http2 default_server;
@solancer
solancer / GoMgo-Config.go
Last active October 22, 2021 10:22
GoMgo-Config.go
// mgo driver.
package main
import (
"github.com/globalsign/mgo"
"github.com/globalsign/mgo/bson"
"log"
"sync"
"time"
)
@solancer
solancer / Install Ruby Gems on Mac OS X without sudo
Created January 3, 2017 15:21
Install Ruby Gems on Mac OS X without sudo
Install Ruby Gems on Mac OS X without sudo
1. Add GEM_HOME to your .bash_profile
For example, nano ~/.bash_profile and add
export GEM_HOME=/Users/srinivas/.gem where the path is to your own Home folder
2. Add the gem executables to your system path
Also in .bash_profile, add
@solancer
solancer / countryCodeFlag.json
Created June 4, 2020 06:07
Country code and flag json dump
[
{
"countryName": "Afghanistan",
"countryCode": "AF",
"callingCode": "+93",
"flag": "https://upload.wikimedia.org/wikipedia/commons/9/9a/Flag_of_Afghanistan.svg"
},
{
"countryName": "Aland Islands",
"countryCode": "AX",
@solancer
solancer / funcPatterns.js
Created April 7, 2020 10:15
funcPatterns for JS
let getDimentions = (length, height) => ({length, height});
// It is same as
getDimentions = (length, height) => {
return {length: length, height: height};
};
// function arguments defaults: Old way
getDimentions = (length, height) => {
if (!length) {