Skip to content

Instantly share code, notes, and snippets.

View reciosonny's full-sized avatar
🎯
Focusing

Sonny R. Recio reciosonny

🎯
Focusing
View GitHub Profile
@reciosonny
reciosonny / ImageResizer.cs
Created December 29, 2016 15:57
Image resizer
/// <summary>
/// Resizes the image for compression
/// </summary>
/// <param name="img"></param>
/// <param name="maxWidth"></param>
/// <param name="maxHeight"></param>
/// <returns></returns>
private static Image ResizeImage(Image img, int maxWidth, int maxHeight) {
if (img.Height < maxHeight && img.Width < maxWidth) return img;
using (img) {
@reciosonny
reciosonny / ds.csv
Created October 10, 2021 01:55 — forked from masrab/ds.csv
Visual data structure selector
Name Indexing (Average) Search (Average) Insertion (Average) Deletion (Worst) Indexing (Worst) Search (Worst) Insertion (Worst) Deletion (Worst) Space
Basic Array O(1) O(n) Undefined Undefined O(1) O(n) Undefined Undefined O(n)
Dynamic Array O(1) O(n) O(n) O(n) O(1) O(n) O(n) O(n) O(n)
Singly-Linked List O(n) O(n) O(1) O(1) O(n) O(n) O(1) O(1) O(n)
Doubly-Linked List O(n) O(n) O(1) O(1) O(n) O(n) O(1) O(1) O(n)
Skip List O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(n) O(n) O(n) O(n) O(n log(n))
Hash Table Undefined O(1) O(1) O(1) Undefined O(n) O(n) O(n) O(n)
Binary Search Tree O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(n) O(n) O(n) O(n) O(n)
Cartresian Tree Undefined O(log(n)) O(log(n)) O(log(n)) Undefined O(n) O(n) O(n) O(n)
B-Tree O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(log(n)) O(n)
<template>
<div>
<div class="error-panel callout alert" v-if="categoryError">
<h2>
Invalid category selected: '{{ selectionJson.rootCategory }}<span v-if="selectionJson.category">/{{ selectionJson.category }}</span>'.
</h2>
<div class="sub-text">
To continue browsing, please return to the <ps-page-navigator page="home" link-text="home page"></ps-page-navigator>.
</div>
</div>
@reciosonny
reciosonny / component-using-mixin-sample1.vue
Last active October 4, 2021 04:51
Vue - Reused similar functionalities using mixins
<template>
<div class="plp-wrapper" :class="{'adjust-wrapper-background-scroll-plp': dockFacetMenuListToTop}">
<facet-menu-list-reflektion
:rfk-facets="rfkFacets"
:facet-selections="selectedFacets"
:preselected-facets="urlParams"
:rfk-page-config="rfkPageConfig"
:rfk-sort-options="rfkSortOptions"
id="facet-menu-list"
:class="{ 'ps-is-stuck' : !inView.stickyWrapper && (isTouchScreen || storeScrollPosition > minimumScrollPositionForFacetsSticky), 'adjust-with-warning-without-toolbar': stickyWarningOn && !inView.stickyWrapper, 'dock-facets-to-top': dockFacetMenuListToTop && !stickyWarningOn}"
/**
* @param {number} k
*/
var MyCircularQueue = function(k) {
this.arr = new Array(k);
this.headCount = 0;
this.tailCount = 0;
};
/**
const webpack = require("webpack");
const webpackMerge = require("webpack-merge");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const path = require("path");
const modeConfig = env => require(`./modes/webpack.${env}.js`)(env);
const pluginConfig = require("./loadPlugins");
module.exports = ({ mode, presets } = { mode: "development", presets: [] }) => {
//uppercase.js
function uppercase(str, callback) {
callback(str.toUpperCase())
}
module.exports = uppercase
//uppercase.test.js
const uppercase = require('./src/uppercase')
test(`uppercase 'test' to equal 'TEST'`, (done) => {
import SoundPlayer from './sound-player';
const mockPlaySoundFile = jest.fn();
jest.mock('./sound-player', () => {
return jest.fn().mockImplementation(() => {
return {playSoundFile: mockPlaySoundFile};
});
});
@reciosonny
reciosonny / webpack.config.dev.js
Last active February 21, 2020 02:29
Webpack 4 staple configuration #webpack
var webpack = require("webpack");
var path = require("path");
var HtmlWebpackPlugin = require("html-webpack-plugin");
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = {
entry: {
bundle: './src/index.js'
},
output: {
@reciosonny
reciosonny / componentHooks.js
Last active December 22, 2019 06:31
componentHooks.js
function App() {
const [initialized, setInitialized] = useState(false);
const [clicked, setClicked] = useState(false);
useEffect(() => {
setInitialized(true);
});