Skip to content

Instantly share code, notes, and snippets.

View levonlee's full-sized avatar
🎯
Focusing

misterlcanada levonlee

🎯
Focusing
View GitHub Profile
@levonlee
levonlee / color.php
Created March 5, 2023 17:51
PHP Color Shade and Tint
<?php
$currentR = 66;
$currentG = 85;
$currentB = 123;
$effect = 'tint';
$alpha = 0.1;
list($aR, $aG, $aB) = (function () use ($effect) {
@levonlee
levonlee / Main.php
Created July 28, 2022 14:59
Explore an option to add capabilities to a class without making it bigger
<?php
class A {
public static function methodA1(): string {
return __METHOD__;
}
}
class B {
@levonlee
levonlee / index.html
Created September 10, 2021 20:45
Performance of Update 500 Elements One Shot vs. Update 33.33% Elements One By One
<div id="content"></div>
<script>
var iterations = 10000;
var numElements = 500;
var everyOtherNumberOfElementsToChange = 3;
var partialPercent = Math.round(1 / everyOtherNumberOfElementsToChange * 100);
var t0 = 0;
var t1 = 0;
var timeOneShot = 0;
@levonlee
levonlee / index.html
Last active May 16, 2018 23:27
Test HTTP Response Header Content-Security-Policy
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src https://cdn.example.net; child-src 'none'; object-src 'none'">
<meta http-equiv="X-Custom-CSP" content="default-src https://cdn.example.net; child-src 'none'; object-src 'none'">
<meta name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Title</title>
</head>
@levonlee
levonlee / index.html
Created December 8, 2017 18:38
Owl Carousel + Bootstrap Modal + Bootstrap Carousel
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Slideshow</title>
<link rel="stylesheet" href="/inventory/owlcarousel/assets/owl.carousel.min.css">
<link rel="stylesheet" href="/inventory/owlcarousel/assets/owl.theme.default.min.css">
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"
integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb"
@levonlee
levonlee / dfp.html
Created September 11, 2017 21:29
Interstial JW Player on DFP
// Place this as Custom Code on DFP
// https://support.jwplayer.com/customer/portal/articles/1406723
<script src="//content.jwplatform.com/libraries/PLAYERID.js"> </script>
<div style="width:300px;height:250px;" id="InterstitialDiv"></div>
<script type="text/javascript">
(function() {
'use strict';
var temp = '%%VIEW_URL_UNESC%%';
window.onload = function() {
function receiveMessage(e) {
@levonlee
levonlee / index.html
Created September 7, 2017 16:33
Anti AdBlocker
<head>
<script src="js/mockingbird.js"></script>
<script type='text/javascript'>
var newcomGlobal = {};
newcomGlobal.ads = 0;
googletag.cmd.push(function () {
googletag.defineSlot('...', [728, 90], 'div-gpt-ad-1339169074361-4');
googletag.defineOutOfPageSlot('...', 'div-gpt-ad-1403025754774-0-oop')
.addService(googletag.pubads());
@levonlee
levonlee / index.html
Created May 20, 2016 17:06
HTML: Add an announcement box on the top of the website
<body>
<div class="alert-box">
<span class="badge">Announcement</span> Some Text
</div>
</body>
@levonlee
levonlee / Schedule Large Feeds Imports using drush and shell script.md
Created May 4, 2016 19:11
Extend Drupal drush_feeds_import module to schedule large feeds import jobs using shell script

Turn off Periodic import in Feeds Import UI Extend dursh_feeds_import module to have more drush commands (drush_feeds_import.drush.inc)

  • See import progress: drush feeds-state --feed-id=feed_importer_1
  • Add watchdog (type:Feeds): drush feeds-log --m="some message"
  • Unlock a feed if it's locked: drush feeds-unlock --feed-id=feed_importer_1 Use shell scripts to run large imports in schedule
  • import-a-feed.sh starts a feed import. If the feed is locked because import progress or clear progress is not completed, the feed will be unlocked and a whole new import will be started
  • import-all-daily-feeds.sh imports all feeds.