Skip to content

Instantly share code, notes, and snippets.

View Tynael's full-sized avatar
🎯
Focusing

Carol Pelu Tynael

🎯
Focusing
View GitHub Profile
@Tynael
Tynael / gist:60b651a5912b70ceb22db016b9719fba
Created April 27, 2017 07:53
OpenCart addToCart Bug Fix
/* -- addToCart -- */
document.getElementById(\"button-cart\").addEventListener(\"click\", raAddToCart);
function raAddToCart(){
_ra.addToCart({$mouseOverAddToCart_product_id}, ".(($product_details['quantity'] > 0) ? 1 : 0).", false, function() {
console.log('addToCart FIRED!')
});
};
// Finds the length of the longest consecutive 1s
// in a binary representation of a given number.
function maxConsecutiveOnes(x)
{
// Initialize result
let count = 0;
while (x != 0)
{
x &= (x << 1);
@Tynael
Tynael / README.md
Last active April 11, 2025 07:03
How to use npx to run gist based scripts
@Tynael
Tynael / example.java
Created May 3, 2021 08:21
Java Code Example
public class MineSweeper {
private int[][] myTruth;
private boolean[][] myShow;
public void cellPicked(int row, int col) {
if (inBounds(row, col) && !myShow[row][col]) {
myShow[row][col] = true;
if (myTruth[row][col] == 0) {
for (int r = -1; r <= 1; r++)
for (int c = -1; c <= 1; c++) cellPicked(row + r, col + c);
}
@Tynael
Tynael / example.cpp
Created May 3, 2021 08:24
C++ Code Example
#include <stdio.h>
#include <time.h>
#include <windows.h>
#include <stdlib.h>
int main() {
struct tm * tmp;
time_t s;
for (;;) {
@Tynael
Tynael / example.html
Created May 3, 2021 08:26
JavaScript Code Example
<!DOCTYPE html>
<title>My Example</title>
<time id="date"></time>
<script>
/*
Create a JavaScript Date object for the current date and time,
then extract the desired parts, then join them again in the desired format.
*/
@Tynael
Tynael / example.html
Created May 3, 2021 08:29
PHP Code Example
<html>
<head>
<title>A File Upload Script</title>
</head>
<body>
<div>
<?php
if ( isset( $_FILES['fupload'] ) ) {
@Tynael
Tynael / example.py
Created May 3, 2021 08:32
Python Code Example
import urllib
import re
print "we will try to open this url, in order to get IP Address"
url = "http://checkip.dyndns.org"
print url
request = urllib.urlopen(url).read()
@Tynael
Tynael / clone-quick-start.bash
Created May 3, 2021 08:37
Clone the Quick Start repository
# Clone the Quick Start repository
$ git clone https://github.com/electron/electron-quick-start
# Go into the repository
$ cd electron-quick-start
# Install the dependencies and run
$ npm install && npm start
@Tynael
Tynael / file-structure.config
Created May 3, 2021 08:39
Electron App File Structure
electron-quick-start
   - index.html
   - main.js
   - package.json
   - render.js