Skip to content

Instantly share code, notes, and snippets.

View dinks's full-sized avatar

Dinesh Vasudevan dinks

View GitHub Profile
@dinks
dinks / test.sh
Created May 29, 2019 13:51
Remove duplicates from File preserving order
awk '!visited[$0]++' your_file > deduplicated_file
[
{
"text_eng": "primary school",
"text_spa": "escuela primaria"
},
{
"text_eng": "teacher",
"text_spa": "profesor / profesora"
},
{
@dinks
dinks / draw-waveform.js
Created February 27, 2018 10:29 — forked from jussi-kalliokoski/draw-waveform.js
Waveform drawing
function getAudioData (url, time) {
return new Promise(function (resolve, reject) {
var context = new AudioContext();
var track = new Audio(url);
var bufferLength = time * context.sampleRate;
var buffer = new Float32Array(bufferLength);
var collector = context.createScriptProcessor(0, 1);
var audioSource = context.createMediaElementSource(track);
var samplesCollected = 0;
@dinks
dinks / INSTRUCTIONS.md
Created August 17, 2017 08:28
Enter passphrase for key fix for ssh
  • ssh-add -K ~/.ssh/id_rsa Note: change the path to where your id_rsa key is located.

  • ssh-add -A

  • Create (or edit if it exists) the following ~/.ssh/config file:

    Host *
      UseKeychain yes
    

AddKeysToAgent yes

@dinks
dinks / simple.jsx
Created September 23, 2015 22:20
Simple jsx
/** @jsx React.DOM */
var HelloMessage = React.createClass({
render: function() {
return <div>{'Hello ' + this.props.name}<div>;
}
});
React.renderComponent(<HelloMessage name="John" />, document.getElementById('container'));
@dinks
dinks / budget_app.jsx
Created September 23, 2015 22:07
reflux Stuff
var BudgetApp = React.createClass({
mixins: [Reflux.connect(EntryStore, 'entries')],
render: function() {
return (
);
}
});
@dinks
dinks / Add swap
Last active September 1, 2015 14:45 — forked from nghuuphuoc/Add swap
Fix MySQL issue "Fatal error: cannot allocate memory for the buffer pool" on Digital Ocean server
// Check swap
$ sudo swapon -s
Filename Type Size Used Priority --> empty
// Create and enable swap file
$ sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k
$ sudo mkswap /swapfile
Setting up swapspace version 1, size = 262140 KiB
no label, UUID=103c4545-5fc5-47f3-a8b3-dfbdb64fd7eb
@dinks
dinks / mock_geocoder.rb
Created June 5, 2015 20:06
Mock Geocoder
# /spec/support/mock_geocoder.rb
# Used with ffaker
RSpec.configure do |c|
class MockResult < ::Geocoder::Result::Base
def initialize(data = [])
super(data)
end
end
@dinks
dinks / 404.sh
Created May 29, 2015 14:41
Ips for 404 on Apache Logs
cat /var/log/apache2/access.log |grep " 404 " | awk '{print $1}' | sort -n | uniq -c | sort -nr
@dinks
dinks / mw_spec.rb
Created May 26, 2015 14:26
Test Middleware in Rails
require 'spec_helper'
describe MyMiddleWare do
let(:app) { ->(env) { [200, env, ""] } }
let :middleware do
MyMiddleWare.new(app)
end
let(:params) do
{
input: data