Skip to content

Instantly share code, notes, and snippets.

View balvinder294's full-sized avatar
๐Ÿ˜Ž
Working Remotey

Balvinder Singh balvinder294

๐Ÿ˜Ž
Working Remotey
View GitHub Profile
@balvinder294
balvinder294 / csp-sample-jhipster.java
Created September 23, 2019 09:08
Sample for Content Security Policy(CSP) in JHipster
/************
Content Security policy Jhipster
**********/
/* Use directives as per your requirement like image-src and default-src for defaults of all*/
// Single line CSP
.headers()
.contentSecurityPolicy("default-src 'self';")
// Multi Line CSP joined by and
@balvinder294
balvinder294 / push-github-service.js
Created August 7, 2019 11:33
Push Repo online To Github via nodejs
// change current directory to repo directory in local
shellJs.cd('path/to/repo/folder');
// Repo name
const repo = 'dummy'; //Repo name
// User name and password of your GitHub
const userName = 'username';
const password = 'password';
// Set up GitHub url like this so no manual entry of user pass needed
const gitHubUrl = `https://${userName}:${password}@github.com/${userName}/${repo}`;
// add local git config like username and email
@balvinder294
balvinder294 / zabbix-docker-compose.yml
Created July 11, 2019 11:39
Zabbix running in Docker Compose with Postgres, Graffana, Adminer
version: '3.1'
services:
postgres-server: # The Postgres Database Service
image: postgres:latest
restart: always
environment: # Username, password and database name variables
POSTGRES_USER: zabbix
POSTGRES_PASSWORD: zabbix
POSTGRES_DB: zabbix
PG_DATA: /var/lib/postgresql/data/pgdata #data storage
@balvinder294
balvinder294 / oauth-popup.ts
Last active March 22, 2023 10:19
Popup window for Oauth Login
// authorization code and tokens
authorizationCode: string;
oAuthToken: string;
oAuthVerifier: string;
// popup related
private windowHandle: Window; // reference to the window object we will create
private intervalId: any = null; // For setting interval time between we check for authorization code or token
private loopCount = 600; // the count until which the check will be done, or after window be closed automatically.
private intervalLength = 100; // the gap in which the check will be done for code.
String completeProfileDetailsUrl = "https://api.linkedin.com/v1/people/~:" +
"(id,industry,summary,specialties,headline,public-profile-url," +
"first-name,last-name," +
"positions:(id,title,summary,start-date,end-date,is-current," +
"company:(id,name,type,size,industry,ticker))," +
"educations:(id,school-name,field-of-study,start-date,end-date,degree,activities,notes)," +
"interests," +
"date-of-birth," +
"picture-urls::(original)," +
"languages:(id,language:(name),proficiency:(level,name))," +
@balvinder294
balvinder294 / fetch-file-from-url-spring-boot.java
Last active July 17, 2024 15:33
Fetch Image from URL and save locally in Spring Boot(Java)
Url imageUrl = new Url("https://site.com/image.jpeg"); // Sample url, replace with yours
String destinationFile = "sample.jpg";
/*******************Multipart Upload Method*********************************
** To resources like minio or DB
***************************************************************************/
/********
* Step 1
@balvinder294
balvinder294 / google-service.java
Last active December 4, 2025 11:43
Sample Code Google Login Oauth2 Java Api
// Required for Http Request and json management for credentials
HttpTransport httpTransport = new NetHttpTransport();
JacksonFactory jsonFactory = new JacksonFactory();
// Go to the Google API Console, open your application's
// credentials page, and copy the client ID and client secret.
// Then paste them into the following code.
String clientId = "YOUR_CLIENT_ID";
String clientSecret = "YOUR_CLIENT_SECRET";
@balvinder294
balvinder294 / gist:7adf37718f52193c4e988ef49ca2db91
Created March 29, 2019 14:30
Video player in 18.04 shows a psychedelic mixture instead of a clear video
I had the same problem when playing a MP4 video, totem/gnome-videos displays a purplish corrupted video output and I have done the following:
From the terminal sudo apt-get remove gstreamer1.0-vaapi
I have done a test and yes, the problem has been fixed now I can see the video correctly.
So the problem is gstreamer1.0-vaapi
Best Regards,
@balvinder294
balvinder294 / pom.xml
Created February 26, 2019 18:47
Spark Maven Dependencies
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-core -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.3.3</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
@balvinder294
balvinder294 / spark-compose.yml
Created February 26, 2019 18:44
Spark Compose.yml
version: "2.2"
services:
master:
image: gettyimages/spark
command: bin/spark-class org.apache.spark.deploy.master.Master -h master
hostname: master
environment:
MASTER: spark://master:7077
SPARK_CONF_DIR: /conf
SPARK_PUBLIC_DNS: localhost