Skip to content

Instantly share code, notes, and snippets.

View manjufy's full-sized avatar
💭
Building Stuff

Manjunath Reddy manjufy

💭
Building Stuff
View GitHub Profile
@manjufy
manjufy / flatten_nested_json.ex
Created April 8, 2017 11:53 — forked from poteto/flatten_nested_json.ex
Flatten deeply nested Map in Elixir
defmodule Json do
def flatten(%{} = json) do
json
|> Map.to_list()
|> to_flat_map(%{})
end
def flatten(%{} = json) when json == %{}, do: %{}
defp to_flat_map([{_k, %{} = v} | t], acc), do: to_flat_map(Map.to_list(v), to_flat_map(t, acc))
defp to_flat_map([{k, v} | t], acc), do: to_flat_map(t, Map.put_new(acc, k, v))
@manjufy
manjufy / laravel-bootstrap4-pagination.md
Created April 17, 2017 17:16
Laravel 5.2 Bootstrap 4 Pagination
@manjufy
manjufy / 00. tutorial.md
Created July 23, 2017 10:35 — forked from maxivak/00. tutorial.md
Importing/Indexing database (MySQL or SQL Server) in Solr using Data Import Handler
@manjufy
manjufy / s3etag.sh
Created August 21, 2017 14:15 — forked from emersonf/s3etag.sh
A Bash script to compute ETag values for S3 multipart uploads on OS X.
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 file partSizeInMb";
exit 0;
fi
file=$1
if [ ! -f "$file" ]; then
@manjufy
manjufy / UniqueObjects.js
Last active September 8, 2017 09:25
Find unique objects from an array
'use strict';
const data = [{
name: "Schumacher",
races: 97
}, {
name: "Vettel",
age: 45
}, {
name: "Hamilton",
@manjufy
manjufy / nginx.conf
Created November 20, 2017 05:52 — forked from mreschke/nginx.conf
Nginx config for multiple laravel sites based on /api/v1 url paths
# This config will host your main [Laravel] GUI application at /, and any additional [Lumen] webservices at /api/v1 and /api/v2...
# This also works perfectly for all static file content in all projects
# This is full of debug comments so you can see how to print debug output to browser! Took me hours to nail this perfect config.
# Example:
# http://example.com - Main Laravel site as usual
# http://example.com/about - Main Laravel site about page as usual
# http://example.com/robots.txt - Main Laravel site static content as usual
# http://example.com/api/v1 - Lumen v1 api default / route
# http://example.com/api/v1/ - Lumen v1 api default / route
@manjufy
manjufy / digitalocean-centos-wordpress.sh
Created December 25, 2017 11:26 — forked from reitermarkus/digitalocean-centos-wordpress.sh
Install WordPress on DigitalOcean CentOS Droplet with PHP 7
#!/bin/sh
DATABASE_NAME='wordpress'
DATABASE_USER='wordpress'
ROOT_MYSQL_PASSWORD=`dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 -w 0 | rev | cut -b 2- | rev`
WORDPRESS_MYSQL_PASSWORD=`dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 -w 0 | rev | cut -b 2- | rev`
# Write Passwords to File.
var x =
{
toString: function()
{
return "foo";
},
valueOf: function() {
return 42;
}
};
@manjufy
manjufy / csv-string-to-json.js
Created February 6, 2018 05:14
JavaScript/NodeJs CSV String to JSON
//var csv is the CSV file with headers
function csvJSON(csv){
var lines=csv.split("\n");
var result = [];
var headers=lines[0].split(",");
for(var i=1;i<lines.length;i++){