Skip to content

Instantly share code, notes, and snippets.

@amiralles
amiralles / doubly_linked_list.rb
Last active November 6, 2021 09:29
Doubly linked lists implemented in ruby
require_relative "./linked_list.rb"
class DoublyLinkedList < LinkedList
class Node < LinkedList::Node
attr_accessor :prev
end
# Inserts a new item into the list.
# Complexity: O(1).
def insert data
@amiralles
amiralles / linked_list.rb
Last active June 10, 2020 09:07
Singly linked list implemented in ruby
class LinkedList
class Node
attr_accessor :next, :data
def initialize data
self.data = data
self.next = nil
end
end
attr_accessor :head, :tail, :length
@braginteractive
braginteractive / gulpfile.js
Created August 13, 2018 19:41
Gulp 4 and WordPress Development
// Load all the modules from package.json
var gulp = require( 'gulp' ),
plumber = require( 'gulp-plumber' ),
autoprefixer = require('gulp-autoprefixer'),
watch = require( 'gulp-watch' ),
jshint = require( 'gulp-jshint' ),
stylish = require( 'jshint-stylish' ),
uglify = require( 'gulp-uglify' ),
rename = require( 'gulp-rename' ),
notify = require( 'gulp-notify' ),
@jthomas
jthomas / package.json
Last active September 24, 2023 21:58
Using TensorFlow.js with MobileNet models for image classification on Node.js
{
"name": "tf-js",
"version": "1.0.0",
"main": "script.js",
"license": "MIT",
"dependencies": {
"@tensorflow-models/mobilenet": "^0.2.2",
"@tensorflow/tfjs": "^0.12.3",
"@tensorflow/tfjs-node": "^0.1.9",
"jpeg-js": "^0.3.4"
@deepesh141291
deepesh141291 / index.html
Created July 15, 2018 04:51
Lazy Loading CSS Background Images with Intersection Observer
<div class="wrapper">
<div class="lazy-background img"></div>
<div class="lazy-background img"></div>
<div class="lazy-background img"></div>
<div class="lazy-background img"></div>
<div class="lazy-background img"></div>
</div>
@bcnzer
bcnzer / postman-pre-request.js
Last active July 22, 2024 10:59
Postman pre-request script to automatically get a bearer token from Auth0 and save it for reuse
const echoPostRequest = {
url: 'https://<my url>.auth0.com/oauth/token',
method: 'POST',
header: 'Content-Type:application/json',
body: {
mode: 'application/json',
raw: JSON.stringify(
{
client_id:'<your client ID>',
client_secret:'<your client secret>',
// Example of how to zip a directory
var gulp = require('gulp');
var zip = require('gulp-zip');
gulp.task('zip', function () {
return gulp.src([
'./**/*',
'!./{node_modules,node_modules/**/*}',
'!./assets/{sass,sass/*}',
'!./gulpfile.js',
@sdnts
sdnts / example.md
Last active January 10, 2023 20:50
Postman pm.sendRequest example

To send a request via the sandbox, you can use pm.sendRequest.

pm.test("Status code is 200", function () {
    pm.sendRequest('https://postman-echo.com/get', function (err, res) {
        pm.expect(err).to.not.be.ok;
        pm.expect(res).to.have.property('code', 200);
        pm.expect(res).to.have.property('status', 'OK');
    });
});
@hteumeuleu
hteumeuleu / fake-background-image.html
Created July 18, 2017 20:45
Fake background with a real image in email
<!DOCTYPE html>
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" lang="en">
<head>
<meta charset="UTF-8" />
<title>Fake background in emails</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!--[if mso]>
<xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
@bvaughn
bvaughn / react-lifecycle-cheatsheet.md
Last active October 8, 2024 15:46
React lifecycle cheatsheet

React lifecycle cheatsheet

Method Side effects1 State updates2 Example uses
Mounting
componentWillMount Constructor equivalent for createClass
render Create and return element(s)
componentDidMount DOM manipulations, network requests, etc.
Updating
componentWillReceiveProps Update state based on changed props