Skip to content

Instantly share code, notes, and snippets.

@rambuvn
rambuvn / slider-fullwidth.liquid
Created June 4, 2022 05:50
Shopify Section Full Width Slider: Create a section that display slider combine with swiperjs
<div class="rb-slider swiper-container">
<!-- Slider main container -->
<div class="swiper">
<!-- Additional required wrapper -->
<div class="swiper-wrapper">
<!-- Slides -->
{% for block in section.blocks %}
<div class="swiper-slide">
<img src="{{ block.settings.image | image_url }}" />
</div>
@rambuvn
rambuvn / gist:3690013
Created September 10, 2012 09:51
Strip some html tag without strip_tags
function strip_html_tags( $text )
{
$text = preg_replace(
array(
// Remove invisible content
'@<head[^>]*?>.*?</head>@siu',
'@<style[^>]*?>.*?</style>@siu',
'@<script[^>]*?.*?</script>@siu',
'@<object[^>]*?.*?</object>@siu',
'@<embed[^>]*?.*?</embed>@siu',
@rambuvn
rambuvn / minesweeper.js
Last active August 28, 2019 08:25
active mine without mouse click http://minesweeperonline.com/#200
var rbMouse = {
x: 0,
y: 0
};
$(document).on('mousemove', function(evt){
rbMouse = {
x: evt.clientX,
y: evt.clientY
}
});
@rambuvn
rambuvn / gist:10961432
Last active May 27, 2018 21:47
Show list questions in specify category or tag
add_shortcode( 'dwqa-list-questions-with-taxonomy', 'dwqa_archive_question_shortcode' );
function dwqa_archive_question_shortcode( $atts ) {
global $script_version, $dwqa_sript_vars;
extract( shortcode_atts( array(
'taxonomy_category' => '',//Use slug
'taxonomy_tag' => '',//Use slug
), $atts, 'bartag' ) );
ob_start( array( $this, 'sanitize_output' ) );
$('.stretch-text').each(function(index, el) {
var line = $(el);
line.html('<span class="stretch-it">'+line.text()+'</span>');
var text = line.find('.stretch-it' );
var textLength = line.text().length,
textWidth = text.width();
var spacing = line.width() - textWidth;
var lt_spacing = spacing / textLength;
@rambuvn
rambuvn / gist:8416162
Created January 14, 2014 10:14
Twitter Follow to Do Something
<div id="rb-follow-button"></div>
<script>
window.twttr = (function (d,s,id) {
var t, js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return; js=d.createElement(s); js.id=id;
js.src="https://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs);
return window.twttr || (t = { _e: [], ready: function(f){ t._e.push(f) } });
}(document, "script", "twitter-wjs"));
twttr.ready(function(twttr){
@rambuvn
rambuvn / gist:5590620
Created May 16, 2013 09:45
developing facebook menu
var ondrag = false,
pointStart = lastPoint = distance = currentTranslate = 0;
$(window).on('mousedown mousemove mouseup touchmove touchstart touchend',function(event){
console.log( event );
switch(event.type) {
case 'touchstart':
case 'mousedown':
ondrag = true;
pointStart = lastPoint = event.pageX || event.originalEvent.touches[0].pageX;
break;
@rambuvn
rambuvn / gist:5308525
Created April 4, 2013 07:30
allow to edit comment on the articles which are not theirs
function rb_add_role( $allcaps, $caps, $args ){
global $post;
if( 'edit_comment' == $args[0] ) {
foreach ($caps as $cap) {
if( ! array_key_exists($cap, $allcaps) ) {
$allcaps[$cap] = 1;
}
}
}
return $allcaps;
@rambuvn
rambuvn / gist:3956712
Created October 26, 2012 03:32
new check of wordpress
/*-----------------------------------------------------------------------------------*/
/* Get newest post day of each category
/*-----------------------------------------------------------------------------------*/
if ( !function_exists( 'wallpress_is_new_post' ) ) :
function wallpress_is_new_post( $post_id ) {
//Get newest point of time of each category, must be newest and lessthan 3 days
$categories = get_the_category( $post_id );
foreach ( $categories as $category ) {
$date = wallpress_newest_post_category( $category->cat_ID );
$post_date = get_the_time( 'Y-m-d', $post_id );
@rambuvn
rambuvn / gist:3904593
Created October 17, 2012 09:02
my hook, allow all user can edit comment ( subscriber )
//Trick allow user subscriber can edit comment
function nex_update_cap($allcaps){
//print_r($allcaps);
global $comment;
if( !empty($comment) ){
global $current_user;
if( $current_user->ID == $comment->user_id ){
$allcaps['edit_others_posts'] = 1;
$allcaps['edit_published_posts'] = 1;