Skip to content

Instantly share code, notes, and snippets.

View dhavaln's full-sized avatar
💭
I may be slow to respond.

Dhaval Nagar dhavaln

💭
I may be slow to respond.
View GitHub Profile
@wesbos
wesbos / async-await.js
Created February 22, 2017 14:02
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}

[based on a true story]

So. Your friend's about to teach you how to make a website. Great!

You make a file, and you save it as 'index.html'. Why it's called 'index' isn't really explained to you, but whatever.

You type the following.

hello world
@pbolduc
pbolduc / 1. Install Redis
Last active July 3, 2023 09:39 — forked from nghuuphuoc/1) Install
Install redis on CentOS 7
# see How to Install Redis Server on CentOS 7 - http://linoxide.com/storage/install-redis-server-centos-7/
# --- Compiling ---
$ yum install gcc make tcl
$ REDIS_VER=3.2.3
$ wget http://download.redis.io/releases/redis-$REDIS_VER.tar.gz
$ tar xzvf redis-$REDIS_VER.tar.gz
$ cd redis-$REDIS_VER
$ make
$ make test
@gaearon
gaearon / connect.js
Last active April 11, 2024 06:46
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
import React from "react";
import { render } from "react-dom";
const ParentComponent = React.createClass({
getDefaultProps: function() {
console.log("ParentComponent - getDefaultProps");
},
getInitialState: function() {
console.log("ParentComponent - getInitialState");
return { text: "" };
@ifraixedes
ifraixedes / LICENSE
Last active May 6, 2018 06:44
AWS lambda handler which download images from S3, resizes them and upload the new ones to S3; tested with mocha, chai, sinon and proxyquire
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004
(http://www.wtfpl.net/about/)
Copyright (C) 2015 Mario Mendes (@hyprstack)
Copyright (C) 2015 Ivan Fraixedes (https://ivan.fraixed.es)
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
@megafaunasoft
megafaunasoft / povray_lambda.js
Created February 2, 2015 21:23
Using AWS Lambda and povray to render images
var async = require('async');
var AWS = require('aws-sdk');
var util = require('util');
var spawn = require('child_process').spawn;
var fs = require('fs');
var s3 = new AWS.S3();
// globals
var dstBucket = "outrender1121"
@rmondello
rmondello / gist:b933231b1fcc83a7db0b
Last active April 5, 2024 07:10
Exporting (iCloud) Keychain and Safari credentials to a CSV file

Exporting (iCloud) Keychain and Safari credentials to a CSV file

Update (October 2021)

Exporting password + one-time code data from iCloud Keychain is now officially supported in macOS Monterey and Safari 15 (for Monterey, Big Sur, and Catalina). You can access it in the Password Manager’s “gear” icon (System Preferences > Passwords on Monterey, and Safari > Passwords everywhere else), or via the File > Export > Passwords... menu item). You shouldn't need to hack up your own exporter anymore.

Original, Obsolete Content (2014)

After my dad died, I wanted to be able to have access any of his online accounts going forward. My dad was a Safari user and used iCloud Keychain to sync his credentials across his devices. I don’t want to have to keep an OS X user account around just to access his accounts, so I wanted to export his credentials to a portable file.

@PomepuyN
PomepuyN / SettingsAdapter.java
Last active June 5, 2018 09:02
Functional example of WearableListView
public class SettingsAdapter extends WearableListView.Adapter {
private final Context context;
private final List<SettingsItems> items;
public SettingsAdapter(Context context, List<SettingsItems> items) {
this.context = context;
this.items = items;
}
@allenhwkim
allenhwkim / gist:be508558869f322e7697
Created October 22, 2014 14:48
Angular Google Maps Fit Bounds
<!doctype html>
<html ng-app="myapp">
<head>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script src="http://code.angularjs.org/1.2.25/angular.js"></script>
<script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script>
<script>
var app = angular.module('myapp', ['ngMap']);
app.controller('MyCtrl', function($scope) {
$scope.positions = [ [-24,132] ,[-25,131] ,[-26,130] ];