Skip to content

Instantly share code, notes, and snippets.

View wisnubaldas's full-sized avatar
🐢
Focusing

wisnu baldas wisnubaldas

🐢
Focusing
View GitHub Profile
@wisnubaldas
wisnubaldas / Palindrom
Created January 8, 2019 02:30
Palindrom
<?php
class Palindrome
{
public static function isPalindrome($string) {
//remove all spaces
$string = str_replace(' ', '', $string);
//remove special characters
$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string);
@wisnubaldas
wisnubaldas / sources.list
Created June 24, 2019 08:48 — forked from h0bbel/sources.list
/etc/apt/sources.list for Ubuntu 18.04.1 LTS Bionic Beaver
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted
#--------------------------------------------------------------------
# Example Environment Configuration file
#
# This file can be used as a starting point for your own
# custom .env files, and contains most of the possible settings
# available in a default install.
#
# By default, all of the settings are commented out. If you want
# to override the setting, you must un-comment it by removing the '#'
# at the beginning of the line.
@wisnubaldas
wisnubaldas / .env
Created August 12, 2019 16:07 — forked from yajra/.env
Laravel DataTables Editor Snippets
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:2JTqUn+p24WXtpVdoIyoK3cIaMOMpeuKvE7vEIlShlg=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=sqlite
BROADCAST_DRIVER=log
@wisnubaldas
wisnubaldas / env
Created October 7, 2019 08:36
now
#--------------------------------------------------------------------
# Example Environment Configuration file
#
# This file can be used as a starting point for your own
# custom .env files, and contains most of the possible settings
# available in a default install.
#
# By default, all of the settings are commented out. If you want
# to override the setting, you must un-comment it by removing the '#'
# at the beginning of the line.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.debug.js" integrity="sha384-NaWTHo/8YCBYJ59830LTz/P4aQZK1sS0SneOgAvhsIl3zBu8r9RevNg5lHCHAuQ/" crossorigin="anonymous"></script>
</head>
<body>

Yeah, This issue I have solved with some trick.

First took the total height of page, using

pageHeight= pdf.internal.pageSize.height;

Then, while adding text into pdf,

pdf.text(x, y, "value");

I am checking this condition everytime,

if (y>=pageHeight) { pdf.addPage(); }

@wisnubaldas
wisnubaldas / create_pdf_from_array.js
Created October 14, 2019 14:34
create pdf from array
const head = [["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","AA","AB","AC","AD","AE","AF","AG","AH","AI","AJ","AK","AL","AM","AN","AO","AP","AQ","AR","AS","AT","AU","AV","AW","AX","AY","AZ","BA","BB","BC","BD","BE","BF","BG","BH","BI","BJ"]]
const body = [
["Rank", "Brand", "1", "", "2", "", "3", "", "4", "", "5", "", "6", "", "7", "", "8", "", "9", "", "10", "", "11", "", "12", "", "13", "", "14", "", "15", "", "16", "", "17", "", "18", "", "19", "", "20", "", "21", "", "22", "", "23", "", "24", "", "25", "", "26", "", "27", "", "28", "", "29", "", "30", ""],
["Profit", "PerM2/Grp", "1/2", "", "2/2", "", "3/2", "", "4/2", "", "5/2", "", "6/2", "", "7/2", "", "8/2", "", "9/2", "", "10/2", "", "11/2", "", "12/2", "", "13/2", "", "14/2", "", "15/2", "", "16/2", "", "17/2", "", "18/2", "", "19/2", "", "20/2", "", "21/2", "", "22/2", "", "23/2", "", "24/2", "", "25/2", "", "26/2", "", "27/2", "", "28/2", "", "29/2", "", "30/2", ""],
["Kode Bar
Enterprise: NJVYC-BMHX2-G77MM-4XJMR-6Q8QF
Professional: KBJFW-NXHK6-W4WJM-CRMQB-G3CDH
Keys are generic ones. These are the same from MSDN account.
Product Key : -6Q8QF
Validity : Valid
Product ID : 00369-90000-00000-AA703
Advanced ID : XXXXX-03699-000-000000-00-1032-9200.0000-0672017
@wisnubaldas
wisnubaldas / vanilla-ajax-poll.js
Created February 5, 2020 03:11 — forked from twmbx/vanilla-ajax-poll.js
Polling in JS with an async ajax call that returns a promise ( modified from: https://davidwalsh.name/javascript-polling )
// The polling function
function poll(fn, timeout, interval) {
var endTime = Number(new Date()) + (timeout || 2000);
interval = interval || 100;
var checkCondition = function(resolve, reject) {
var ajax = fn();
// dive into the ajax promise
ajax.then( function(response){
// If the condition is met, we're done!