Skip to content

Instantly share code, notes, and snippets.

View aamirafridi's full-sized avatar

Aamir Afridi aamirafridi

  • London
View GitHub Profile
@aamirafridi
aamirafridi / reverse-doubly.js
Created August 18, 2020 22:23
Reversing a doubly linked list in Javascript
function reverse(head) {
let nextNode = null;
let prevNode = null;
let currentNode = head;
while(currentNode) {
nextNode = currentNode.next;
currentNode.prev = nextNode;
currentNode.next = prevNode;
prevNode = currentNode;
currentNode = nextNode;
function rotLeft(a, d) {
if (a.length === d) return a;
// arrays are Non-Primitive data type so create a shallow copy
var copy = [...a];
while(d) {
copy.push(copy.shift());
d--;
}
@aamirafridi
aamirafridi / Accordion.jsx
Created December 10, 2017 11:34
React Accordion Component
import "./index.css";
import React, { Component } from "react";
class Accordion extends Component {
static defaultProps = {
onChange: () => {},
statusIconsComponents: {
opened: "▲",
closed: "▼"
},
@aamirafridi
aamirafridi / SassMeister-input.scss
Created June 5, 2015 09:16
Generated by SassMeister.com.
// ----
// libsass (v3.2.4)
// ----
%message {
border: 1px solid #ccc;
padding: 5px;
display: block;
}
@aamirafridi
aamirafridi / SassMeister-input.scss
Last active August 29, 2015 14:22
Generated by SassMeister.com.
// ----
// libsass (v3.2.4)
// ----
%message {
border: 1px solid #ccc;
padding: 5px;
display: block;
}
@aamirafridi
aamirafridi / SassMeister-input.scss
Created June 5, 2015 09:14
Generated by SassMeister.com.
// ----
// libsass (v3.2.4)
// ----
%message {
border: 1px solid #ccc;
padding: 5px;
display: block;
}
.error {
@aamirafridi
aamirafridi / SassMeister-input.scss
Created June 5, 2015 09:13
Generated by SassMeister.com.
// ----
// libsass (v3.2.4)
// ----
%message {
border: 1px solid #ccc;
padding: 5px;
display: block;
}
.error {
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@aamirafridi
aamirafridi / Detect_CSS3_Animation_Browser_Support.js
Last active January 2, 2016 03:18
Detecting CSS3 Transition support using Javascript. If supported than return the prefix and the eventName
//Working demo can be found on http://codepen.io/aamirafridi/pen/GcmHt
//HTML: <div>click me to animate</div>
function supportTransitions() {
var b = document.body || document.documentElement,
s = b.style,
p = 'transition',
e = {
'Webkit' : 'webkitTransitionEnd',