Skip to content

Instantly share code, notes, and snippets.

View cawabunga's full-sized avatar
:shipit:

Emil Ibatullin cawabunga

:shipit:
View GitHub Profile
@grGred
grGred / GasOptimizations.md
Last active March 31, 2024 07:18
Solidity gas optimizations and tricks

Upgrade pragma to latest Solidity compiler version


Using newer compiler versions and the optimizer gives gas optimizations and additional safety checks for free!

The advantages of versions 0.8.* over <0.8.0 are:

  • Safemath by default from 0.8.0 (can be more gas efficient than some library based safemath).
  • Low level inliner from 0.8.2, leads to cheaper runtime gas. Especially relevant when the contract has small functions. For example, OpenZeppelin libraries typically have a lot of small helper functions and if they are not inlined, they cost an additional 20 to 40 gas because of 2 extra jump instructions and additional stack operations needed for function calls.
  • Optimizer improvements in packed structs: Before 0.8.3, storing packed structs, in some cases used an additional storage read operation. After [EIP-
@zinovyev
zinovyev / webpacker_helper.rb
Created March 28, 2019 21:34
Rails helper for loading controller specific assets managed by Webpacker
module WebpackerHelper
def page_pack_tags
join_paths(application_pack_tags,
controller_pack_tags)
end
def application_pack_tags
join_paths(attempt_to_find(:stylesheet, 'application'),
attempt_to_find(:javascript, 'application'))
end
@ibraheem4
ibraheem4 / postgres-brew.md
Last active July 5, 2024 17:29 — forked from sgnl/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@keithmorris
keithmorris / drive-format-ubuntu.md
Last active July 4, 2024 09:06
Partition, format, and mount a drive on Ubuntu
define(['angular'], function(angular){
var module = angular.module('utils.cache', ['restmod')
// Cache implementation for angular-restmod
// https://github.com/platanus/angular-restmod/issues/27
module.factory('CacheModel', function(restmod){
var mixin = restmod.mixin(function() {
@drio
drio / server_allow_cross_domain_requests.py
Created June 16, 2013 17:04
Python server that allows cross domain requests.
#!/usr/bin/env python
import SimpleHTTPServer
class MyHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def end_headers(self):
self.send_my_headers()
SimpleHTTPServer.SimpleHTTPRequestHandler.end_headers(self)
def send_my_headers(self):
@jfsiii
jfsiii / index.html
Last active January 4, 2021 18:11
Full-Screen Layout using Flexbox
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Holy Grail</title>
<style>
/* some basic styles. nothing to do with flexbox */
header, footer,
nav, article, aside {
border: 1px solid black;
@brenes
brenes / model_extension.rb
Last active February 14, 2024 11:39
Removing validation of a model declared on a gem
# We have to remove validations on email, as it's no longer needed.
# Based on a solution found at http://stackoverflow.com/questions/7545938/how-to-remove-validation-using-instance-eval-clause-in-rails
Model.class_eval do
_validators.reject!{ |key, _| key == :field }
_validate_callbacks.each do |callback|
callback.raw_filter.attributes.delete :field
end
@kurtmilam
kurtmilam / deep_extend_javascript_objects_underscore_mixin.js
Last active October 3, 2020 14:56
Deep Extend / Merge Javascript Objects - underscore.js Mixin
/* Copyright (C) 2012-2014 Kurt Milam - http://xioup.com | Source: https://gist.github.com/1868955
*
* This mixin now has its own github repository: https://github.com/kurtmilam/underscoreDeepExtend
* It's also available through npm and bower
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFR
@vojtajina
vojtajina / angular-bc.js
Created January 20, 2012 21:51
Angular: BC module for scope/controller separation
/**
* @license AngularJS
* (c) 2010-2012 AngularJS http://angularjs.org
* License: MIT
*/
/**
* Backward compatibility module for AngularJS
* @author Vojta Jina <vojta.jina@gmail.com>
*