Skip to content

Instantly share code, notes, and snippets.

@vtanathip
vtanathip / custom-indicator-sma
Last active November 21, 2024 14:14
Example Basic Pine Script
//@version=5
indicator("Dynamic Table Example with Colors", overlay=true)
// Inputs
smaLength = input.int(20, title="SMA Length", minval=1)
upColor = input.color(color.new(color.green, 0), title="Bullish Color")
downColor = input.color(color.new(color.red, 0), title="Bearish Color")
neutralColor = input.color(color.new(color.gray, 0), title="Neutral Color")
// Function to calculate the trend for a specific timeframe
@vtanathip
vtanathip / How to download google drive VDO without permission
Last active August 7, 2024 08:20
Download vdo from google drive steps
# Steps to download file
- Open the link that contains VDO that you want to download
- Open chrome dev tools
- Go to Network tab
- Play a VDO
- Fitler on Network tab with "videoplayback"
- Copy one of them and open in another tab (this step you need to pay attention on url, it need to remove "&range" parameter till the end of url out
- Now you will able to download the VDO but no audio in it
- Back to Network tab again and looking for smallest file of "videoplayback" result
- Do the same steps above to download audio file
@vtanathip
vtanathip / gist:3e14a6afe34b10337c7712e0bea9509e
Created April 26, 2024 06:53
Sample question for test fundamental knowledge of JS
export {};
function findClosestNumber(arr: number[], target: number): number {
// Sort the array in ascending order
arr.sort((a, b) => a - b);
let closest: number = arr[0];
let minDifference: number = Math.abs(target - closest);
arr.forEach((num) => {
@vtanathip
vtanathip / gitignore-android-studio-list
Last active July 23, 2024 10:09
Git Ignore files list that should use in Android Studio Projects
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
@vtanathip
vtanathip / A-way-to-initial-mongodb-data-with-grunt.js
Last active July 1, 2017 07:35
This is the way to insert initial data into MongoDB via grunt task. Thx to this plugin: https://github.com/sindresorhus/grunt-shell
//this is json array that MongoDB will easier read and import into it
//for the record if you didn't use json array MongoDB will read data per line so don't forget to re-format it
[
{ name: "Widget 1", desc: "This is Widget 1" },
{ name: "Widget 2", desc: "This is Widget 2" }
]
@vtanathip
vtanathip / A-config-to-clean-everytime-test-report-generated.js
Last active December 21, 2015 21:08
Config karma.conf.js to show code coverage report and clean every-time to run server. ( Then just run unit test and it will auto-generate file by istanbul engine )
clean: {
dist: {
files: [{
dot: true,
src: [
'.tmp',
'<%= yeoman.dist %>/*',
'!<%= yeoman.dist %>/.git*'
]
}]
@vtanathip
vtanathip / Angular-config-e2e-testing.js
Created August 27, 2013 13:57
Sometime when you use yeoman you must add more config to Gruntfiles.js & karma-e2e.conf.js to complete it. the easiest to test e2e in angular is open server with grunt and add proxies to karma-e2e.conf.js then run it. By the way I found that sometimes when you use old version of angular-generator yo will fail when run test (it will start up but …
//add this config to karma-e2e.conf.js
// Uncomment the following lines if you are using grunt's server to run the tests
proxies = {
'/': 'http://localhost:9000/'
};
// URL root prevent conflicts with the site root
urlRoot = '_karma_';
@vtanathip
vtanathip / Angular-Directive-Mock.js
Created August 26, 2013 15:37
In Angular when you want to unit test directive with templateUrl you must compile html to js and put it in $templateCache for use it ( solution is very easy with this plugin https://github.com/ericclemmons/grunt-angular-templates )
ngtemplates: {
myApp: {
options: {
base: 'app/templates', // $templateCache ID will be relative to this folder
prepend: 'templates/', // path to your templates files ( this will add path to it )
module: {
name: 'myAppTemplate', // (Optional) Explicitly define module name
define: true // (Optional) Define new module (Default: false)
}
},
@vtanathip
vtanathip / Angular-Controller-Mock.js
Last active December 21, 2015 15:29
Example AngularJS Controller Unit Testing ( Mock all Services dependencies )
'use strict';
angular.module('angularApp')
.controller('MainCtrl', function ($scope, $rootScope, loadConfig) {
//services dependecies ( should be mock )
$scope.loadConfig = loadConfig.getConfig('main', $rootScope.lang);
//function change route
$scope.createRoute = function(link) {
@vtanathip
vtanathip / Angular-Services-Mock.js
Last active December 21, 2015 15:19
Example AngularJS Services Unit Testing ( Mock all $http dependencies )
angular.module('angularApp')
.factory('loadConfig', function($http) {
return {
getPageInfo : function(page) {
return $http.get('configurations/en/' + page + '.json').then(
function(response) {
return response.data;
});
}