Skip to content

Instantly share code, notes, and snippets.

View onurozkan's full-sized avatar

Onur Özkan onurozkan

View GitHub Profile
@AshikNesin
AshikNesin / react-file-upload.js
Created February 2, 2017 06:46
Simple React File Upload
import React from 'react'
import axios, { post } from 'axios';
class SimpleReactFileUpload extends React.Component {
constructor(props) {
super(props);
this.state ={
file:null
}
@pmhoudry
pmhoudry / trixUpload.js
Last active May 7, 2021 16:37
Trix upload button in VanillaJs
(function() {
// Adding upload button to Trix toolbar on initialization
document.addEventListener('trix-initialize', function(e) {
trix = e.target;
toolBar = trix.toolbarElement;
// Creation of the button
button = document.createElement("button");
button.setAttribute("type", "button");
button.setAttribute("class", "attach");
@paulirish
paulirish / what-forces-layout.md
Last active May 17, 2024 18:01
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@thebucknerlife
thebucknerlife / authentication_with_bcrypt_in_rails_4.md
Last active January 17, 2024 23:54
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

@SerhiiKozachenko
SerhiiKozachenko / repository.js
Created August 6, 2013 21:54
Mongoose odm and repository pattern.
var mongoose = require('mongoose');
var repository = function (modelName) {
var self = this;
self.Model = require('../models/' + modelName);
self.FindById = function (id, cb) {
self.FindOne({
@pete-otaqui
pete-otaqui / happytime-amd.js
Last active February 10, 2018 18:00
A better setTimeout, setInterval and requestAnimationFrame, wrapped as an AMD module and fine for many JSHint setups.
/*
See http://paulirish.com/2011/requestanimationframe-for-smart-animating/
and http://blog.joelambert.co.uk/2011/06/01/a-better-settimeoutsetinterval/
*/
define([
],
function () {
'use strict';
@TCotton
TCotton / media-query-testing.css
Last active December 15, 2015 07:58
Media query testing on different devices
@media only screen and (max-width:1280px) and (-webkit-min-device-pixel-ratio: 1.0),
only screen and (max-width:1280px) and (min-resolution: 120dpi) {
/* ipad 3 portrait / landscape
ipad 2 portrait / landscape
ipad 1 portrait / landscape
amazon kindle fir hd portrait
nexus 7 landscape
Samsung Galaxy Note 10.1 landscape
Samsung Galaxy Tab 2 10.1 landscape
LG Nexus 4 portrait
@n1k0
n1k0 / 404checker.js
Created January 11, 2013 10:55
A CasperJS script to check for 404 & 500 internal links on a given website
/**
* This casper scipt checks for 404 internal links for a given root url.
*
* Usage:
*
* $ casperjs 404checker.js http://mysite.tld/
* $ casperjs 404checker.js http://mysite.tld/ --max-depth=42
*/
/*global URI*/
@pies
pies / ExcelFormulas.js
Created November 29, 2012 04:55
Few Excel formulas - PMT, PPMT, XIRR - expressed in Javascript
/* Based on
* - EGM Mathematical Finance class by Enrique Garcia M. <egarcia@egm.co>
* - A Guide to the PMT, FV, IPMT and PPMT Functions by Kevin (aka MWVisa1)
*/
var ExcelFormulas = {
PVIF: function(rate, nper) {
return Math.pow(1 + rate, nper);
},