Skip to content

Instantly share code, notes, and snippets.

View meldsza's full-sized avatar

Melroy Dsouza meldsza

View GitHub Profile
@meldsza
meldsza / MergeCategory.js
Last active July 30, 2017 12:09
Move all topics from one category to another and delete the current category - Discourse
/**
Please Note that this script is for Discourse Forum
To move all posts in the CURRENT category to another category
For example i want to move all the topics in the current category to category number 70
Just open the category. open Developer tools, paste this in the console and type the command moveAndDeleteCategory("70")
You can get the category id by going to /site.json
*/
function whenElementExistsThenDo(selector, fn, count) {
if (!count) count = 0;
@meldsza
meldsza / LoadAll.js
Last active July 30, 2017 12:31
A script to load to the end of a page in discourse - Helps to select all posts in a topic by loading them and then using bulk action
let load = function(){
if($('a:contains("Why not create a topic?")').length > 0)
return console.log("LoadAll: Loading Complete")
setTimeout(function(){
$("html, body").animate({ scrollTop: $(document).height() }, 1);
load()
},10)
}
load()
@meldsza
meldsza / index.js
Last active August 16, 2019 04:17
Pass pm2 logs to discord via webhook
const webhook_uri = "WEBHOOK URL HERE";
const spawn = require('child_process').spawn;
const request = require('request');
var pm2 = false;
let queue = [];
function createChunks(str) {
return str.match(new RegExp('.{1,' + 2000 + '}', 'g'));
}
function send(data) {
const config = {
filepath: "./file.log",
line_delimiter: "\n",
line_should_contain: "permit",
to_remove: [/[\r\n]/g],
original_column_delimiter: " ",
columns_to_be_removed: [1, 2, -1, -2]
}
const fs = require('fs');
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define MAX_SIZE 100
struct
{
int top;
char items[MAX_SIZE];
} typedef Stack;
@meldsza
meldsza / Palindrome.c
Created August 22, 2018 15:55
Palindrome dont ignore spacing
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define MAX_SIZE 100
struct
{
int top;
char items[MAX_SIZE];
} typedef Stack;
/**
Infix to postfix
Write a C program to convert and print a given valid parenthesized infix arithmetic expression to postfix expression. The expression consists of single character operands and +,-, *, / operators.
Constraints: only four operators used +, -, *, / .
Input format:
Input consists of a string which consists of infix expression.
The output consists of an postfix expression. If the input In-fix expression consists of an operator other than Arithmetic operators mentioned above print "Invalid Input".
Refer sample input and output for formatting specifications.
@meldsza
meldsza / circularqueue.c
Last active September 6, 2018 06:34
QUEUE
#include <stdio.h>
#include <stdlib.h>
#define MAX_SIZE 3
struct{
int front;
int rear;
int a[MAX_SIZE];
int size;
} typedef Queue;
void insert(Queue*, int);
@meldsza
meldsza / circularLinkedList.c
Created October 3, 2018 12:48
Circular Linked List using head in C lang
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node
{
int info;
struct node *next;
};
typedef struct node *Node;
@meldsza
meldsza / singlyLinkedList.c
Created October 3, 2018 13:13
Singly Linked List for a list of Students with id , sem and name featuring insertion of Node at a position and delete Rear
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node
{
int id;
char name[50];
int sem;
struct node *next;