Skip to content

Instantly share code, notes, and snippets.

View samsoft00's full-sized avatar
🏠
Working from home

Oyewole Samuel A. samsoft00

🏠
Working from home
View GitHub Profile
exports.getLists = async (query) => {
const sort = { _id: -1 }
// Max of 30 records
query.limit = parseInt(query.limit || 10)
const limit = query.limit > 30 ? 30 : query.limit
let hasNext = false
let hasPrev = false
const q = {
@samsoft00
samsoft00 / generator.js
Created January 18, 2022 14:32
Class to generate random number.
export class Generator {
// constructor (private readonly len: number = 6) {}
len: number = 10
randomNumber (): string {
return Math.floor(
Math.pow(10, this.len - 1) +
Math.random() * (Math.pow(10, this.len) - Math.pow(10, this.len - 1) - 1)
).toString()
}
require("dotenv").config({ path: "../.env" });
const express = require("express");
const bodyParser = require("body-parser");
const graphqlHttp = require("express-graphql");
const graphqlSchema = require("../graphql/schema");
const graphqlResolver = require("../graphql/resolver");
const app = express();
const port = 8080;
@samsoft00
samsoft00 / word_encryptor.ts
Last active September 13, 2019 00:21
Word Encryption using crypto
import * as crypto from 'crypto';
export default class WordEncryptor{
salt: Buffer;
algorithm: string;
key:Buffer;
iv: Buffer;
constructor(password: string) {
this.salt = crypto.randomBytes(32);
@samsoft00
samsoft00 / java_collection_example.java
Created August 6, 2016 05:55
Java Collect Example
import java.util.ArrayList;
public class AList {
public static void main(String[] args){
ArrayList<Integer> grades = new ArrayList<Integer>();
grades.add(100);
grades.add(90);
grades.add(80);
grades.add(70);
grades.add(60);
@samsoft00
samsoft00 / web-fonts-asset-pipeline.md
Created July 11, 2016 09:49 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

@samsoft00
samsoft00 / genymotionwithplay.txt
Last active September 7, 2015 13:40 — forked from wbroek/genymotionwithplay.txt
Genymotion with Google Play Services
Download the following ZIPs:
ARM Translation Installer v1.1 (http://www.mirrorcreator.com/files/0ZIO8PME/Genymotion-ARM-Translation_v1.1.zip_links)
Download the correct GApps for your Android version:
Google Apps for Android 5.1 (https://www.androidfilehost.com/?fid=96042739161892865 - gapps-L-4-21-15.zip)
Google Apps for Android 5.0 (https://www.androidfilehost.com/?fid=95784891001614559 - gapps-lp-20141109-signed.zip)
Google Apps for Android 4.4.4 (https://www.androidfilehost.com/?fid=23501681358544845 - gapps-kk-20140606-signed.zip)
Google Apps for Android 4.3 (https://www.androidfilehost.com/?fid=23060877490000124 - gapps-jb-20130813-signed.zip)
Google Apps for Android 4.2 (https://www.androidfilehost.com/?fid=23060877490000128 - gapps-jb-20130812-signed.zip)
package com.samsoft.cbc.keepsafe;
import android.app.AlertDialog;
import android.app.Service;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
public Bitmap blurBitmap(Bitmap bitmap){
//Let's create an empty bitmap with the same size of the bitmap we want to blur
Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
//Instantiate a new Renderscript
RenderScript rs = RenderScript.create(getApplicationContext());
//Create an Intrinsic Blur Script using the Renderscript
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));