Skip to content

Instantly share code, notes, and snippets.

View dineshsonachalam's full-sized avatar

Dinesh Sonachalam dineshsonachalam

View GitHub Profile
@dineshsonachalam
dineshsonachalam / Python_3_dev_prerequisite.md
Last active May 31, 2021 02:24
Prerequisite for Python3 development
  1. Set Python3 as a default python version on your MacOS.
# Step 1: Install Python3 using homebrew
$ brew install python

# Step 2: Look for the path where the latest python3 is available
dineshsonachalam@macbook ~ % ls -l /usr/local/bin/python*
lrwxr-xr-x  1 dineshsonachalam  admin  24 May 30 11:31 /usr/local/bin/python -> /usr/local/bin/python3.9
# Here we are creating an image for python alphine image.(https://hub.docker.com/r/library/python/)
FROM python:3
# Copying the requirements.txt first to leverage Docker cache
COPY ./requirements.txt /app/requirements.txt
# WORKDIR is nothing but current directory (cd app)
WORKDIR /app
# Install the requirements in the current directory.
@r6m
r6m / slice_exists.go
Last active November 10, 2019 23:53
golang check if item exists in slice
package main
import(
"fmt"
"reflect"
)
func main() {
items := []int{1,2,3,4,5,6}
fmt.Println(SliceExists(items, 5)) // returns true
@giuseppebonaccorso
giuseppebonaccorso / twitter_sentiment_analysis_convnet.py
Last active March 16, 2020 19:26
Twitter Sentiment Analysis with Gensim Word2Vec and Keras Convolutional Networks
import keras.backend as K
import multiprocessing
import tensorflow as tf
from gensim.models.word2vec import Word2Vec
from keras.callbacks import EarlyStopping
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Flatten
from keras.layers.convolutional import Conv1D
@gboeing
gboeing / pypi.md
Last active June 17, 2022 16:11
How to organize and distribution a package on pypi

To distribute a package on pypi

Directory structure

/project/
    /package/
        __init__.py
        module.py
 setup.py
var path = require('path');
module.exports = {
entry: path.resolve(__dirname, 'src') + '/app/index.js',
output: {
path: path.resolve(__dirname, 'dist') + '/app',
filename: 'bundle.js',
publicPath: '/app/'
},
package main
import "fmt"
func swap(x, y *int) {
var z = *x
*x = *y
*y = z
}
@lgueye
lgueye / validate-es-behaviour.sh
Created February 7, 2012 14:45
elasticsearch : dealing with case and accents
# delete index (will print an error if 'my_index' doesn't exist, you can safely ignore it)
curl -XDELETE 'http://localhost:9200/my_index'
# create index with its settings
curl -XPOST 'http://localhost:9200/my_index' -d '{
"index.analysis.analyzer.default.type":"custom",
"index.analysis.analyzer.default.tokenizer":"standard",
"index.analysis.analyzer.default.filter.0":"lowercase",
"index.analysis.analyzer.default.filter.1":"asciifolding"
}'
@diorahman
diorahman / client.html
Created December 26, 2011 03:34
Ajax, call jQuery POST to node.js expressjs
<html>
<head>
<title>jsonp test</title>
<script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
$(function(){
$('#select_link').click(function(e){
e.preventDefault();
console.log('select_link clicked');
@karmadude
karmadude / node-mysql2json.js
Created December 8, 2011 03:34
Using Node to export MySQL query results to a file as JSON
// https://github.com/felixge/node-mysql
// npm install mysql
var mysql = require('mysql');
// http://nodejs.org/docs/v0.6.5/api/fs.html#fs.writeFile
var fs = require('fs');
var client = mysql.createClient({
user: 'root',
password: 'mysqlpassword'