Skip to content

Instantly share code, notes, and snippets.

View Ikhiloya's full-sized avatar

Ikhiloya Ikhiloya

View GitHub Profile
@Ikhiloya
Ikhiloya / console.sql
Last active October 9, 2018 14:21
Delete a table with foreign key constraints mysql
set foreign_key_checks = 0;
drop table sla_matrix_config cascade;
set foreign_key_checks = 1;
--OR--
drop table gender_tab cascade constraints;
@Ikhiloya
Ikhiloya / Table If-else.html
Created October 19, 2018 08:57
If Else in a html table (Angular)
<td *ngIf="(question.responseType === 'F');
else pickListResponse">Free Text</td>
<ng-template #pickListResponse>
<td>Pick List</td>
</ng-template>
@Ikhiloya
Ikhiloya / is_int()
Created October 25, 2018 22:28
Function to check if a number is of type 'int'
def is_int(x):
if( (abs(x) - (abs(int(x)))) > 0 ):
return False
else:
return True
@Ikhiloya
Ikhiloya / digit_sum.py
Created October 25, 2018 22:34
A simple function that sums the digit of a number
"""A simple function that sums the digit of a number"""
# x could be any number such as 1234, the function will result in (1 + 2 + 3 + 4) = 10
def digit_sum(x):
string_val = str(x)
sum = 0
for i in string_val:
sum += int(i)
return sum
@Ikhiloya
Ikhiloya / factorial.py
Created October 25, 2018 22:42
A simple function that computes the factorial of a number
def factorial(x):
fact = 1
for i in range(x):
fact *= i + 1
return fact
@Ikhiloya
Ikhiloya / is_prime.py
Created October 25, 2018 22:53
Function to check for prime numbers
def is_prime(x):
if(x < 2 ):
return False
if(x == 2):
return True
for n in range(2, x):
if(x % n == 0):
return False
return True
@Ikhiloya
Ikhiloya / reverse_text.py
Created October 25, 2018 23:14
function to reverse a string
def reverse(text):
string_len = len(text)
new_word = ''
for i in text:
new_word += text[string_len -1]
string_len -=1
return new_word
@Ikhiloya
Ikhiloya / delete notes.txt
Created November 2, 2018 10:15
Delete all records from a table in SQL
delete and truncate :
delete from mytable
This will delete all the content of the table, not reseting the autoincremental id, this process is very slow. If you want to delete specific records append a where clause at the end.
truncate myTable
This will reset the table i.e. all the auto incremental fields will be reset. Its a DDL and its very fast. You cannot delete any specific record through truncate.
@Ikhiloya
Ikhiloya / delete notes.txt
Created November 2, 2018 10:15
Delete all records from a table in SQL
delete and truncate :
delete from mytable
This will delete all the content of the table, not reseting the autoincremental id, this process is very slow. If you want to delete specific records append a where clause at the end.
truncate myTable
This will reset the table i.e. all the auto incremental fields will be reset. Its a DDL and its very fast. You cannot delete any specific record through truncate.
@Ikhiloya
Ikhiloya / anti_vowel.py
Created November 3, 2018 06:41
anti_vowel
def anti_vowel(text):
result = ""
vowels = "ieaouIEAOU"
for char in text:
if char not in vowels:
result += char
return result
print anti_vowel("hello book")