Skip to content

Instantly share code, notes, and snippets.

# We multiply 10s 4 times together to get 10000
print(10*10*10*10)
print(2*2*2*2*2)
from math import log, ceil
print(log(10000, 10)) # how many times do we multiply 10 together to get 10000?
print(log(32, 2)) # how many times do we multiply 2 together to get 32?
@sazid
sazid / book_struct.c
Created April 25, 2017 15:03
Book structure in C
#include <stdio.h>
#include <string.h>
struct Book {
char title[100];
char author[100];
int number_of_pages;
};
int main() {
#include <stdio.h>
// 1. Sum of max numbers from each row
int sum_row_max(int x[3][3]) {
int sum = 0;
int i, j, max;
for (i = 0; i < 3; i++) {
max = x[i][0];
tinymce.init({
selector: 'textarea#doc_editor',
height: 500,
theme: 'modern',
plugins: [
'advlist placeholder autolink lists link image media charmap print preview hr anchor pagebreak',
'searchreplace wordcount visualblocks visualchars code fullscreen',
'insertdatetime media nonbreaking table contextmenu directionality',
'emoticons paste textcolor colorpicker textpattern codesample'
],
#include <stdio.h>
int maxIdx(int x[], int size) {
int i;
int m = x[0];
int idx = 0;
for (i = 0; i < size; i++) {
if (m < x[i]) {
m = x[i];
@sazid
sazid / ARRAY_PROBLEMS.c
Last active March 15, 2017 14:10
C programs for practise
#include <stdio.h>
void main() {
int x[7];
int i;
// ----- START OF 1 ----- //
printf("\n\n1. TAKE INPUT AND SHOW THE RESULT ------------------\n\n");
// TAKE INPUT FROM THE USER
#include <stdio.h>
#include <math.h>
int main()
{
int a, b, c;
double root_1, root_2;
printf("For ax^2 + bx + c = 0 ; give the following inputs.\n");
printf("Input a: ");
@sazid
sazid / masker.py
Created January 17, 2017 16:58
Python character masking/unmasking
def mask_characters(str):
str = str.replace('~', '&#126;')
str = str.replace('!', '&#33;')
str = str.replace('@', '&#64;')
str = str.replace('#', '&#35;')
str = str.replace('$', '&#36;')
str = str.replace('%', '&#37;')
str = str.replace('&', '&#38;')
str = str.replace("'", '&#39;')
str = str.replace('"', '&#34;')
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,
Preference preference) {
super.onPreferenceTreeClick(preferenceScreen, preference);
if (preference != null) {
if (preference instanceof PreferenceScreen) {
if (((PreferenceScreen) preference).getDialog() != null) {
((PreferenceScreen) preference)
.getDialog()
.getWindow()
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if ((intent.getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
!= Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) {
getFragmentManager().popBackStack(null,
FragmentManager.POP_BACK_STACK_INCLUSIVE);
}
}