Skip to content

Instantly share code, notes, and snippets.

View kocoten1992's full-sized avatar
😗
Thanks for visiting

Chuong kocoten1992

😗
Thanks for visiting
View GitHub Profile
@tanaikech
tanaikech / submit.md
Last active May 13, 2024 08:11
Downloading Shared Files on Google Drive Using Curl

Downloading Shared Files on Google Drive Using Curl

When the shared files on Google Drive is downloaded, it is necessary to change the download method by the file size. The boundary of file size when the method is changed is about 40MB.

File size < 40MB

CURL

filename="### filename ###"
fileid="### file ID ###"
curl -L -o ${filename} "https://drive.google.com/uc?export=download&amp;id=${fileid}"
@alecharp
alecharp / keep-jenkins-plugins-uptodate.groovy
Last active December 22, 2022 06:01
Simple groovy script to upgrade active plugins when new versions are available
jenkins.model.Jenkins.getInstance().getUpdateCenter().getSites().each { site ->
site.updateDirectlyNow(hudson.model.DownloadService.signatureCheck)
}
hudson.model.DownloadService.Downloadable.all().each { downloadable ->
downloadable.updateNow();
}
def plugins = jenkins.model.Jenkins.instance.pluginManager.activePlugins.findAll {
it -> it.hasUpdate()
@RichardBronosky
RichardBronosky / README.md
Last active July 19, 2021 09:18
Create a single-file "unified format" ovpn file from the legacy client.ovpn client.key client.crt ca.crt four-file format.

unify-ovpn.sh

  1. cd to the directory where your 4 files are. (client.ovpn, client.key, client.crt, and ca.crt)

  2. Call unify-ovpn.sh with the filename of your ovpn file

     unify-ovpn.sh client.ovpn
    
  3. A new file named client_unified.ovpn will be created

@nikAizuddin
nikAizuddin / knuth_books.sh
Created May 23, 2017 03:36
UNIX Shell script to download four volumes of The Art of Computer Programming by Donald E. Knuth.
#!/bin/sh
################################################################################
## ##
## The Art of Computer Programming by Donald E. Knuth. ##
## ##
################################################################################
## Volume 1 - Fundamental Algorithms, 3rd Edition
@robertpainsi
robertpainsi / commit-message-guidelines.md
Last active May 15, 2024 19:48
Commit message guidelines

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
<?php
/**
* Automatically alias Laravel Model's to their base classname.
* Ex: "App\Models\User" now can just be accessed by "User"
*/
if (! function_exists('aliasModels')) {
function aliasModels() {
$finder = new \Symfony\Component\Finder\Finder();
$finder->files()->name('*.php')->in(base_path().'/app');
@nicowilliams
nicowilliams / fork-is-evil-vfork-is-good-afork-would-be-better.md
Last active May 18, 2024 14:10
fork() is evil; vfork() is goodness; afork() would be better; clone() is stupid

I recently happened upon a very interesting implementation of popen() (different API, same idea) called popen-noshell using clone(2), and so I opened an issue requesting use of vfork(2) or posix_spawn() for portability. It turns out that on Linux there's an important advantage to using clone(2). I think I should capture the things I wrote there in a better place. A gist, a blog, whatever.

This is not a paper. I assume reader familiarity with fork() in particular and Unix in general, though, of course, I link to relevant wiki pages, so if the unfamiliar reader is willing to go down the rabbit hole, they should be able to come ou

@DeviaVir
DeviaVir / mysql-cluster.service
Created March 7, 2017 09:23
MySQL Cluster systemd service
[Unit]
Description=MySQL Cluster server
After=network.target auditd.service
[Service]
ExecStart=/opt/mysql/server-5.7/bin/ndb_mgmd -f /var/lib/mysql-cluster/config.ini
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
@phieber
phieber / takeOverMyVPS.sh
Last active May 21, 2022 02:26
VPS notes for using takeover.sh
#!/bin/bash
# https://github.com/marcan/takeover.sh
#
# Allows to install another Linux flavor like e.g. Gentoo even if the VPS hoster doesn't offer/allow you to do so.
#
# First argument: the deep link to the sysresccd iso image
set -o nounset
/etc/init.d/apache2 stop
@LindaLawton
LindaLawton / GoogleAuthenticationCurl.sh
Last active August 8, 2023 14:08
Curl bash script for getting a Google Oauth2 Access token
# Tutorial https://www.daimto.com/how-to-get-a-google-access-token-with-curl/
# YouTube video https://youtu.be/hBC_tVJIx5w
# Client id from Google Developer console
# Client Secret from Google Developer console
# Scope this is a space seprated list of the scopes of access you are requesting.
# Authorization link. Place this in a browser and copy the code that is returned after you accept the scopes.
https://accounts.google.com/o/oauth2/auth?client_id=[Application Client Id]&redirect_uri=http://127.0.0.1&scope=[Scopes]&response_type=code
# Exchange Authorization code for an access token and a refresh token.