Skip to content

Instantly share code, notes, and snippets.

View puncoz's full-sized avatar
🇳🇵
Working from home

Puncoz Nepal puncoz

🇳🇵
Working from home
View GitHub Profile
@puncoz
puncoz / gh-pages-deploy.md
Created December 1, 2019 16:40 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@puncoz
puncoz / gist:44f8e95e6881856f8104ab2dfb8903a1
Created October 29, 2019 11:41 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@puncoz
puncoz / server.js
Last active September 19, 2019 10:05
Basic CRUD operation in Node.js using express and redis.
// Importing packages
const express = require("express"),
bodyParser = require("body-parser"),
methodOverride = require("method-override"),
redis = require("redis")
// Init application
const app = express()
// initialising body parser
@puncoz
puncoz / NameCase.php
Created July 18, 2019 03:59
Correctly capitalize names in PHP
<?php
/**
* Normalize the given (partial) name of a person.
*
* - re-capitalize, take last name inserts into account
* - remove excess white spaces
*
* Snippet from: https://timvisee.com/blog/snippet-correctly-capitalize-names-in-php
*
@puncoz
puncoz / service-worker.js
Created July 15, 2019 17:27
ServiceWorker.js for Backend Knowledge Sharing #8, https://blog.yipl.com.np/
"use strict"
let cacheVersion = 3
const offlineUrl = "offline-page.html"
self.addEventListener("install", event => {
event.waitUntil(caches.open("offline-cache-" + cacheVersion).then(cache => cache.addAll([
"/index.html",
offlineUrl,
// other more url of files, css, js etc.
@puncoz
puncoz / service-worker-index.html
Created July 15, 2019 17:16
Service worker registering in index.html, Backend Knowledge Sharing #8, https://blog.yipl.com.np/
...
<script>
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("/service-worker.js").then((registration) => {
console.log("Service worker registered successfully with scope: ", registration.scope)
}).catch((error) => {
console.error("Service worker registration failed.", error)
})
} else {
<?php
class UserController
{
/**
* @SWG\Post(path="/user",
* tags={"user"},
* summary="Create user",
* description="This can only be done by the logged in user.",
<?php
class UserController
{
public function lists()
{
// Create a fractal instance
$fractal = new \League\Fractal\Manager();
// to enable links support, we need to set a baseUrl on serializer
@puncoz
puncoz / google-colab-code-snippet.md
Created June 12, 2019 11:16
Some useful code snippets for google colab

To upload file from computer to colab:

from google.colab import files
uploaded = files.upload()

Extract Google Drive zip from Google colab notebook

Mount GDrive:

from google.colab import drive