Skip to content

Instantly share code, notes, and snippets.

View franklinokech's full-sized avatar
🎯
Focusing

franklinokech franklinokech

🎯
Focusing
View GitHub Profile
@franklinokech
franklinokech / upLoadImage.php
Created August 25, 2018 12:10
Code Snippet for uploading images in php
/* file uploading */
$config['upload_path'] = './uploads/intro/';
$config['allowed_types'] = 'gif|jpg|png';
$config['encrypt_name'] = true;
$this->load->library('upload', $config);
if ($this->upload->do_upload('file_to_upload'))
{ $file_data = $this->upload->data();
` $file_name = $file_data['file_name'];
}
@franklinokech
franklinokech / Login.php
Created September 13, 2018 12:45
An animated LoginForm
<!--HTML -->
<div class="owl">
<div class="hand"></div>
<div class="hand hand-r"></div>
<div class="arms">
<div class="arm"></div>
<div class="arm arm-r"></div>
</div>
</div>
<div class="form">
@franklinokech
franklinokech / gs
Last active March 11, 2019 05:36
Google App Script to Concatenate Strings in a Google Spreadsheet
function myFunction() {
var exString="My Name is Franklin"
var numExample=107 % 97
Logger.log(exString[1])
//var exSqrt=Math.sqrt(numExample)
var examLog= Math.log(numExample)
//Logger.log(exSqrt)
Logger.log(examLog)
}
@franklinokech
franklinokech / code.gs
Last active March 11, 2019 23:19
This is a simple google app script that captures what the user has typed in a html textbox and append the value and the current timestamp in a spreadsheet workbook as a row
/*
This function renders the html file
*/
function doGet(event){
Logger.log(event);
return HtmlService.createHtmlOutputFromFile('page');
}
function userClick(name){
@franklinokech
franklinokech / Code.gs
Last active March 12, 2019 07:05
this code snippet represent a modular approach to building google web apps by separating the server side scripts, java scripts and css style sheets in separate files to make it more modular and maintainable.
/*
This function renders the html file
*/
function doGet(event){
return HtmlService.createTemplateFromFile("page").evaluate();
}
function userClick(Userinfo){
@franklinokech
franklinokech / CopyDataBetweenGoogleSheets.gs
Last active March 13, 2019 06:50
changes the name of the file and edited move to copy
/*
A function to copy data from one SpreadSheet to another Spreadsheet
*/
function CopyDataToNewFile() {
var sss = SpreadsheetApp.openById('1beVqbhcXrDTUNDiqbgO9Q-VgXau6ixOOc03BMTNFCqM');//Source spreadsheet ID
var ss = sss.getSheetByName('Data');
var SRange = ss.getDataRange();
var SData = SRange.getValues();
var tss = SpreadsheetApp.openById('1aSXgCJfsEtSZfVQJcfZmwWod2xQbds5PHHTX5_O6rFU');//Target spreadsheet ID
@franklinokech
franklinokech / ShouldTriggerRun.gs
Created March 13, 2019 13:36
Google app script to make a trigger not run on a weekend
function shouldRunTrigger() {
var days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
var date = new Date();
var day = days[date.getDay()];
var hours = date.getHours();
if ((day === "Fri" && hours >= 17) || (day === "Sat" && hours <= 22)) {
return false;
}
return true;
}
@franklinokech
franklinokech / OnEdit.gs
Created March 13, 2019 13:40
Google script app to run some code when A sheet gets edited
function onEdit(event) {
var sheet = event.source.getActiveSheet();
var range = event.source.getActiveRange();
// move
if (sheet.getName() == 'Problems' && range.getColumn() == 12 && range.getValue() == 'Resolved') {
var row = range.getRow();
var numColumns = sheet.getLastColumn();
var tRange = sheet.getRange(sheet.getLastRow() + 1, 1, 1, numColumns);
tRange.setValues(sheet.getRange(row, 1, 1, numColumns).getValues());
tRange.setBackgroundColor('#99ccff');
@franklinokech
franklinokech / GenerateCaseBaseReport.gs
Created March 13, 2019 13:48
Google App Script To get case report from a sheet
I wrote a test function to read ACTIVE sheet values and write different vendor reports in separate sheets. If you wanna know more about my code, let me know in comment.
function test() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = SpreadsheetApp.getActiveSheet();
var values = sheet.getDataRange().getValues();
// remove header row values from array
values.shift();
// will be months present in data
@franklinokech
franklinokech / ClearContentsfromRow.gs
Created March 13, 2019 13:55
A google app script to CLEAR values in a row NB: Dont delete the row
function deleteRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var values = sheet.getDataRange().getValues();
values.forEach(function(v, i) {
// get row index
var row = i+1;
// look for required values in cells
if (v[14] == '' && v[6] == 'PREBOOKED') {
// might have to modify this line based on Sheets API