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 / critical-css-laravel-mix.js
Created September 18, 2018 04:52 — forked from bayareawebpro/critical-css-laravel-mix.js
Generate Critical CSS Paths with Laravel Mix
let mix = require('laravel-mix');
let httpRequest = require('request')
let criticalCSS = require('critical')
//Run your asset compilation commands...
//Then we will generate critical css...
mix.then(()=>{
console.log("Build Post-Processing...")
const criticalRoutes = [
@puncoz
puncoz / responsive-text.js
Created January 7, 2019 08:57
Responsive Text, calculated font-size with respect to content wrapper.
export const responsiveText = (selector) => {
const rtWrappers = document.querySelectorAll(selector)
rtWrappers.forEach(wrapper => {
const width = wrapper.offsetWidth,
height = wrapper.offsetHeight,
text = wrapper.innerHTML
let textLength = typeof text === "string" ? text.trim().replace(" ", "").length : 0
@puncoz
puncoz / deploy.rb
Created January 18, 2019 10:44 — forked from tjhanley/deploy.rb
Capistrano task for creating a change log file
desc "Create about and revision files."
task :rev_deployment, :roles => [:app, :web] do
require 'grit'
require 'chronic'
# include Grit
work_dir = File.join(File.dirname(__FILE__), '../../')
g = Grit::Repo.new(work_dir)
since = Chronic.parse('last week friday')
msg = "\n"
rev_file = File.join(File.dirname(__FILE__), '../../','tmp/revision.txt')
@puncoz
puncoz / php_helpers.php
Last active March 16, 2021 07:28
PHP Useful Helper functions
function _alphaOnly($value)
{
return preg_replace('/[^[:alnum:]\-\.]/u', '', $value);
}
/**
* @param $number
*
* @return string
*/
@puncoz
puncoz / gitflow-breakdown.md
Created April 2, 2019 08:08 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

@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
<?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
<?php
class UserController
{
/**
* @SWG\Post(path="/user",
* tags={"user"},
* summary="Create user",
* description="This can only be done by the logged in user.",
@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 {
@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.