Skip to content

Instantly share code, notes, and snippets.

View antsmartian's full-sized avatar
💭
Hacking...

antsmartian antsmartian

💭
Hacking...
  • India
View GitHub Profile
@antsmartian
antsmartian / Sync.sh
Created July 14, 2012 11:36
Shell script for syn with ntp servers for proper time.
#!/bin/bash
#Call the config file . .
source configFile.sh
#Install ntp on the server
sudo apt-get install ntp
#The config files for ntp lies in /etc/ntp.conf.
#We are changing the Servers time to our nearest geo location.
version: "3"
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.3
networks:
- elastic-jaeger
ports:
- "127.0.0.1:9200:9200"
- "127.0.0.1:9300:9300"
@antsmartian
antsmartian / #insertionSort.groovy
Created February 4, 2012 15:46
Insertion Sort In Groovy
a = [2,34,4,123,45,56,3,56,67,87,21,45,56,67,22,4234,4234,2342,1,34,546,67,677,343,4,41,32,456,1341,13,454,234,453,565,5,524,234,234,5456,567,673,245,567,78,78,324,56576,782,435,676,873,2,345,6767,7,3463,3,6767673,34534,2,345,656,3,5652,1,34345,3453545,35345356,66,7883345,676787,8988]
b = a
long startTime = System.currentTimeMillis();
(1..(a.size()-2)).each { out ->
def temp = a.getAt(out)
def index = out
while(index>0 && a.getAt(index-1) >= temp)
{
value = a.getAt(index-1)
a.putAt(index,value)
/*
1. In JavaScript, define a function `makeCounter` which takes one optional argument defining the intial value, `start`, with a default value of 0. The function should return an object containing keys that define 3 methods: - `value` returns the current value of the counter - `increment` increments the value of the counter by 1 and returns the new value - `decrement` decrements the value of the counter by 1 and returns the new value The returned object should not allow direct modification or retrieval of the value.
Example usage:
var counter = makeCounter();
console.log(counter.value()); // 0
var counter2 = makeCounter(4);
console.log(counter2.value()); // 4
console.log(counter2.increment()); // 5
console.log(counter2.value()); // 5
counter2.decrement();
@antsmartian
antsmartian / version2.groovy
Created April 8, 2012 17:09
Web Scraping using Groovy and Jsoup!
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
println "WebScraping with Groovy \n"
def url = "http://rates.goldenchennai.com/";
def url2 = "http://scores.sify.com/index.shtml"
def document = Jsoup.connect(url).get();
def cricDocument = Jsoup.connect(url2).get()
def goldDetails = document.select(".yellowTxt")
// import {plainToClass} from "class-transformer";
require("@babel/core").transform("code", {
plugins: ["@babel/plugin-proposal-decorators"]
});
/*
{
"id": 1,
"firstName": "Johny",
"lastName": "Cage",
@antsmartian
antsmartian / LEARNING.md
Last active May 11, 2019 20:30
Learning Postgres

Hello all, I'm in the process of learning Postgres and I find it very hard to find a resource where postgres is explained in terms of developer. Since I'm in the process of reading and applying it in my side project; I treat this gist as my knowledge sharing place on Postgres and its features. Each sub-heading tries to explain the concepts of Postgres with simple example. I may be wrong at times here, if so please free to comment.

All the codes are written and run on psql

I would be adding many stuffs as I learn them. There is no particular order in which I add the contents.

I'm using the following postgres version:

SELECT version();
package main
import (
"net"
"os"
"strings"
"fmt"
"syscall"
"time"
"strconv"
@antsmartian
antsmartian / Setup.sh
Created July 12, 2012 08:16
Shell script for auditing in Linux
#!/bin/bash
sudo apt-get install auditd
sudo auditd
#Setting up system parameters
sudo auditctl -b 1000
sudo auditctl -f 1
sudo auditctl -r 5
sudo auditctl -e 1
import React, { Component, createContext } from 'react'
function initStore(store) {
const Context = createContext();
class Provider extends React.Component {
constructor() {
super();
this.state = store.initialState;
}