Skip to content

Instantly share code, notes, and snippets.

class ZombiesController < ApplicationController
def index
if params[:name]
@zombie=Zombie.where(:name => params[:name]).first
@[email protected]
else
@z=Zombie.all
end
end
@owade
owade / codewars_.idea_.name
Last active September 25, 2015 08:22
SOME RUBY CODE CHALLENGES I HAVE BEEN DOING
codewars
@owade
owade / Flat.js
Created August 1, 2022 07:59
Ways to flatten nested array
//stackoverflow
function flatten(arr) {
let i = 0;
if (!Array.isArray(arr)) {
/* return non-array inputs immediately to avoid errors */
return arr;
}
while (i < arr.length) {
@owade
owade / spiralMatrix.js
Created August 27, 2022 09:40
Spiral matrix traversal
let i=0,j=0,res=[];
const traverse = (arr) => {
while(!visited(arr)){
goRight(arr);
goDown(arr);
goLeft(arr);
goUp(arr);
}
return res;
@owade
owade / 01_deployContracts.js
Created February 15, 2023 21:43 — forked from BlockmanCodes/01_deployContracts.js
Uniswap V3 Flashloans and Arbitrage
const { Contract, ContractFactory, utils, BigNumber } = require("ethers")
const WETH9 = require("../WETH9.json")
const artifacts = {
UniswapV3Factory: require("@uniswap/v3-core/artifacts/contracts/UniswapV3Factory.sol/UniswapV3Factory.json"),
SwapRouter: require("@uniswap/v3-periphery/artifacts/contracts/SwapRouter.sol/SwapRouter.json"),
NFTDescriptor: require("@uniswap/v3-periphery/artifacts/contracts/libraries/NFTDescriptor.sol/NFTDescriptor.json"),
NonfungibleTokenPositionDescriptor: require("@uniswap/v3-periphery/artifacts/contracts/NonfungibleTokenPositionDescriptor.sol/NonfungibleTokenPositionDescriptor.json"),
NonfungiblePositionManager: require("@uniswap/v3-periphery/artifacts/contracts/NonfungiblePositionManager.sol/NonfungiblePositionManager.json"),
WETH9,